2

Is there any limitations in the number of notifications we can post at one time. We are posting 2 different kinds of notifications when application comes to the foreground. Handling of these notifications happens from a thread other than main thread. We are seeing few crashes when we keep the device sleep for some time and then awake and bring the application up. It crashes on one of the notification observer handler.

Any clue what could be the reason?

Abhinav
  • 37,684
  • 43
  • 191
  • 309
  • you are using NSNotification default center for this when app comes to foreground ? – Kunal Balani Aug 16 '12 at 19:34
  • Yes. We are posting a notification on NSNotificationCenter: [[NSNotificationCenter defaultCenter] postNotificationName:@"MyNotification" object:nil userInfo:nil]; – Abhinav Aug 16 '12 at 19:35
  • thread used for invoking notification does not matter ... make sure the parameters passed while post match the method signature .. If you get unrecognized seletor message on console ...then for sure this is the issue – Kunal Balani Aug 16 '12 at 19:36
  • what error do you get in console while crashing ??? – Kunal Balani Aug 16 '12 at 19:36
  • It says "EXC_BAD_ACCESS" in crash log. Looks like the object does not exists. It prints the line number as well which is pointing to one of the observer's code. – Abhinav Aug 16 '12 at 19:40
  • ok. enable your zombie (http://stackoverflow.com/questions/5386160/how-to-enable-nszombie-in-xcode) and check if any deallocated instance has been accessed ... this might solve your problem – Kunal Balani Aug 16 '12 at 19:42
  • 2
    For sure some variables have been unloaded in the meanwhile which is quite normal. Check all the variables the handler uses and one of them (if not all) will have lost their value due to unload. You may put some NSLogs in the handler to see when it unloads and loads again... You may have to store your values permanently and fetch them when the app becomes active again - eg using core data – user387184 Aug 16 '12 at 19:49
  • @user387184 if the object is deallocated NSLog will result in a crash . – Kunal Balani Aug 16 '12 at 19:51
  • No I mean put them in the unload method so you see when it unloads... not when it wants to access the variable! – user387184 Aug 16 '12 at 19:51

0 Answers0