This isn’t so much a question as a pondering thought – why does NSNotificationCenter throw an exception when it’s released? I’m still new to iPhone development, and thus don’t know the innards of Cocoa yet, so it’d be good to understand why.
I’m assigning the defaultCenter to a variable, calling addObserver:selector:name:object and then releasing the previous variable, but the call to [notify release] crashes the app. I’m not doing anything strange in the code, so it’d be interesting to find out exactly why it’s doing this.
Anyone ran into this problem?
From what I know of NSNotifcation you shouldn’t be assigning the defaultcenter to a variable but rather doing something like:
In that snippet your calling the default centre and registering the current object for a certain message.
And then to post a message to the notification centre you can use:
I use the above in all my code and don’t have any problems with it.