iPhone NSCFString leaks in fetchRequest
        Posted  
        
            by camilo
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by camilo
        
        
        
        Published on 2010-04-20T12:16:03Z
        Indexed on 
            2010/04/20
            12:43 UTC
        
        
        Read the original article
        Hit count: 340
        
In the following code:
- (NSMutableArray *) fetchNotesForGroup: (NSString *)groupName {
 // Variables declaration
 NSMutableArray *result;
 NSFetchRequest *fetchRequest;
 NSEntityDescription *entity;
 NSSortDescriptor *sortDescriptor;
 NSPredicate *searchPredicate;
 NSError *error = nil;
 // Creates the fetchRequest and executes it
 fetchRequest = [[[NSFetchRequest alloc] init] autorelease];
entity = [NSEntityDescription entityForName:@"Note" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];
sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"noteName" ascending:YES] autorelease];
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
[fetchRequest setReturnsDistinctResults:YES];
searchPredicate = [NSPredicate predicateWithFormat:@"categoryName like %@", groupName];
[fetchRequest setPredicate:searchPredicate];
[fetchRequest setPropertiesToFetch:[NSArray arrayWithObject:@"noteName"]];
result = [[managedObjectContext executeFetchRequest:fetchRequest error:&error] mutableCopy];
 // Variables release
 return result;
}
... I Fetch notes for a given categoryName. When I'm running Instruments, it says that a NSCFString is leaking.
I know leaks are mean for iPhone developers... but I don't have any idea on how to plug this one.
Any clues? All help is welcome.
Thanks a lot!
© Stack Overflow or respective owner