首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何优化UILocalNotification流程

如何优化UILocalNotification流程
EN

Stack Overflow用户
提问于 2011-01-10 02:53:31
回答 1查看 215关注 0票数 1

我尝试在一个实体上使用fetch请求发送多个localNofications,尽管这段代码运行良好

代码语言:javascript
复制
   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 app

1)如果我释放fetchedObjects,应用程序就会崩溃。我不是应该释放它吗?

2)我是否可以使用localNotif.userinfo来优化代码,而不是调用一个方法来使用activeList中的字符串来调度每个localNotification?我想不出该怎么做。

谢谢,

麦克

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-01-13 06:24:02

1) executeFetchRequest返回自动下发的NSArray,无需手动下发

2)不清楚你想优化什么……

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4641064

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档