iphone - App crashes when didFinishLaunchingWithOptions is called -


i have app when notification fired notification bar when app in background ,when tap on bar navigates tableview of notification set . when quit app background receiving notification when tap on notification bar app getting crashed since not getting indexpath of tableview.

when app quit in background , reloading app should enter didfinishlaunching.

in appdidfinishlaunching calling method navigates tableview

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {     self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];     self.viewcontroller = [[ppviewcontroller alloc] initwithnibname:@"viewcontroller_iphone" bundle:nil] ;       uilocalnotification *notification = [launchoptions objectforkey:              uiapplicationlaunchoptionslocalnotificationkey];      if (notification)         {             int remedyid = [[notification.userinfo objectforkey:kremindmenotificationremedyidkey] intvalue];             nsdictionary *reminderdetails =[nsdictionary dictionarywithobjectsandkeys:notification.userinfo,@"kremindmenotificationdatakey",[nsnumber numberwithint:remedyid],kremindmenotificationremedyidkey,nil];              [_viewcontroller gotoreminder:reminderdetails shownotification:yes];         }      [application setstatusbarstyle:uistatusbarstyleblacktranslucent];     self.viewcontroller = [[ppviewcontroller alloc] initwithnibname:@"ppviewcontroller" bundle:nil];     self.window.rootviewcontroller = self.viewcontroller;     [self.window makekeyandvisible];     return yes;  }  **this code navigates tableview in viewcontroller**  - (void)gotoreminder:(nsmutabledictionary *)reminderdictionary shownotification:(bool)shouldshownotification  {     nsindexpath *selectedsymptip = [nsindexpath indexpathforrow:selectedsymptomindex insection:keyindexnumber];      [self tableview:symptomstableview didselectrowatindexpath:selectedsymptip];  } 

when quit app , app starts again, viewcontroller not yet set up. when launching notification, need check if resuming background, or launching normally.

look @ applicationwillenterforeground , applicationdidbecomeactive in uiapplicationdelegate protocol reference how handle resuming app various states. see: http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/managingyourapplicationsflow/managingyourapplicationsflow.html#//apple_ref/doc/uid/tp40007072-ch4-sw3


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -