質問

エンティティでフェッチリクエストを使用して複数のローカルノフィケーションを送信しようとしていますが、このコードは正常に機能しますが

   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)ActiveListの文字列で各ローカル解除をスケジュールするためにメソッドを呼び出す代わりに、Codeを最適化するためにlocalnotif.userinfoを使用してコードを最適化できますか?私はそれをする方法を理解できません。

ありがとう、

マイク

役に立ちましたか?

解決

1)ExecuteFetchRequestオートリリースされたNSARRAYを返します。手動でリリースする必要はありません

2)何を最適化したいですか...

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top