Re: Crashing Problem calling postNotificationName
Re: Crashing Problem calling postNotificationName
- Subject: Re: Crashing Problem calling postNotificationName
- From: Dave <email@hidden>
- Date: Wed, 11 Sep 2013 14:52:15 +0100
On 11 Sep 2013, at 14:22, Graham Cox <email@hidden> wrote:
>
> On 11/09/2013, at 3:13 PM, Dave <email@hidden> wrote:
>
>> Yes, but it doesn't remember the last value of a notification, which is what I would like.
> []
>
>> Yes, I am removing myself as a receiver, but ideally I want to receive these notification even if the object is dead. By this I mean, I want the last known value of the notification restored when the Object in question starts up again. At present I have to save this somewhere ugly and restore it from somewhere ugly. I just thought it would be nice to be able to just make a call something like:
>>
>> -(void) reissueLastNotificationName:@"Note1" forClass:self
>>
>> Rather than save it somewhere ugly 26 more times!
>>
>> I could maybe subclass NSNotificationCenter?
>
>
> There are a couple of statements here that don't make a huge amount of sense. What do you mean by "an object….starts up again"?
I mean when the object is created - at this point I want the latest version of the Notification, not the Notification when the Object Died.
> Perhaps the problem is really that your object should not be being killed until the final notification has been received? That's a different problem.
No, there is no final notification, just one when the data associated with it changes.
> If you mean you want to save something between launches of your app so you can restore state, that's easily done by the sender of the notification.
No, I just want the latest version of the notification when the object is created. Yes, I could save it at the sender, but I'd still have the problem of restoring it when the object is created and wants to set itself to the current state. Basically, when it is created I want it to fetch the latest update and apply it to itself data at init time. I don't want to store the old value.
Think like this:
Object has not been created………..
Send Notification A
Send Notification B
Send Notification C
Send Notification D
Send Notification E
Object is Created……….. Set Data from Notification E
Send Notification F
Object is Alive……….. Set Data from Notification F
Send Notification G
Object is Alive……….. Set Data from Notification G
Object is deleted/released.
Send Notification H
Send Notification I
Send Notification J
Object is Created……….. Set Data from Notification J
> Basically, there isn't enough detail in your question to advise, and what you have given appears to smell a bit. "Reissuing" a notification sounds like a band-aid for a problem that should be solved some other way, to me. Subclassing NSNotificationCenter is presumably possible, but sounds like the wrong way to do whatever it is you are really trying to do.
I want the above, I thought subclassing NSNotificationCenter and adding a memory would be quite a neat way of doing it - 27 times.
All the Best
Dave
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden