我尝试在一个实体上使用fetch请求发送多个localNofications,尽管这段代码运行良好
NSFetchRequest *myRequest = [[NSFetchRequest alloc] init];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"active == YES"];
[myRequest setEntity:[NSEntityDescription entityForName:@"Entry" inManagedObjectContext:managedObjectContext]];
[myRequest setPredicate:predicate];
NSError *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 app1)如果我释放fetchedObjects,应用程序就会崩溃。我不是应该释放它吗?
2)我是否可以使用localNotif.userinfo来优化代码,而不是调用一个方法来使用activeList中的字符串来调度每个localNotification?我想不出该怎么做。
谢谢,
麦克
发布于 2011-01-13 06:24:02
1) executeFetchRequest返回自动下发的NSArray,无需手动下发
2)不清楚你想优化什么……
https://stackoverflow.com/questions/4641064
复制相似问题