2013-05-15 36 views
0

你好我有問題UILocalNotification。我正在從服務器接收通知,我在Mutable array中存儲Json Array。像:Multi UILocalNotification

idnoty *的通知

通知 titlenoty *標題的ID,當我嘗試這種代碼:

UILocalNotification *notif; 
NSMutableArray *notifications = [[NSMutableArray alloc] init]; 
for(int i=0 ; i<[idnoty count]; i++){ 
     notif=[[UILocalNotification alloc]init]; 
    if (notif == nil) return; 

NSLog(@" H LOOP %i",i); 

notif.fireDate = [NSDate date]; 
notif.timeZone = [NSTimeZone defaultTimeZone]; 
[[UIApplication sharedApplication] cancelAllLocalNotifications]; 
UILocalNotification *localNotification = [[UILocalNotification alloc] init]; 
[localNotification setHasAction:YES]; 
localNotification.timeZone = [NSTimeZone localTimeZone]; 
localNotification.alertBody = [titlenoty objectAtIndex:i]; 
localNotification.applicationIconBadgeNumber = i+1; 

    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification ]; 
} 

finaly當我從服務器2個多個通知。此代碼顯示最後的Notitfication。

JSON:代碼

content =  (
       { 
      active = 1; 
      descr = sdescr; 
      entrydate = "2013-05-15"; 
      id = 48; 
      pid = 11; 
      title = dasdsad; 
     }, 
       { 
      active = 1; 
      descr = sdescr; 
      entrydate = "2013-05-16"; 
      id = 49; 
      pid = 11; 
      title = MALAKA; 
     }, 
       { 
      active = 1; 
      descr = sdescr; 
      entrydate = "2013-05-16"; 
      id = 50; 
      pid = 11; 
      title = dasdsadsadsadsadsadsadsagdfggffggfdgdfgdfgdfgdfgdfgdfgdfgdf; 
     } 
    ); 
    "total_rows" = 3; 
} 

感謝

回答

0

你應該每次都不能叫[[UIApplication的sharedApplication] cancelAllLocalNotifications]內循環。