I'm trying to send multiple localNofications using a fetch request on an entity And though this code works fine
NSFetchRequest *myRequest = [[NSFetchRequest alloc] init];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"active == YES"];
[myRequest setEntity:[NSEntityDescription entityForName:@"Entry" inManagedObjectContext:managedObjectContext]];
[myRequest setPredicate:predicate];
NS开发者_高级运维Error *error = nil;
NSArray *fetchedObjects = [self.managedObjectContext executeFetchRequest: myRequest error: &error];
if (fetchedObjects == nil){
// Deal with error...
}
// We fill the NSMutableArray with the values of the fetch
self.activeList = [[NSMutableArray alloc] initWithArray:[fetchedObjects valueForKey:@"textbody"]];
[self scheduleAlarms:[self.activeList objectAtIndex:0]];
[fetchedObjects release]; //this line crashes the app
1) if I release fetchedObjects, the app crashes. Aren't I supposed to release it ?
2) Could I use the localNotif.userinfo to optimize the code instead of calling a method to schedule each localNotification with the strings in my activeList ? I can't figure out how to do it.
Thanks,
Mike
1) executeFetchRequest returns an autoreleased NSArray, you don't need to release it manually
2) not clear what do you want to optimize...
精彩评论