2011-01-09 56 views
1

我試圖發送使用讀取請求多localNofications對實體 而且雖然這代碼,如果我釋放fetchedObjects,應用程序崩潰正常工作如何優化UILocalNotification過程

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)。我不應該釋放它嗎?

2)我可以使用localNotif.userinfo來優化代碼,而不是調用一個方法來調度每個localNotification與我的activeList中的字符串?我無法弄清楚如何去做。

感謝,

邁克

回答

0

1)executeFetchRequest返回一個自動釋放的NSArray,你並不需要手動鬆開

2)不清楚你要優化...

什麼
+0

謝謝。通過優化,我的意思是一次不安排本地通知的方式,我知道可以使用userinfo字典來設置本地通知,但本地通知參考指南對於如何實現本地通知很模糊。 – 2011-01-13 04:22:28