On 11 Sep 2013, at 15:11, dangerwillrobinsondan...@gmail.com wrote:

> 
> On Sep 11, 2013, at 10:52 PM, Dave <d...@looktowindward.com> wrote:
> 
>> 
>> On 11 Sep 2013, at 14:22, Graham Cox <graham....@bigpond.com> wrote:
>> 
>>> 
>>> On 11/09/2013, at 3:13 PM, Dave <d...@looktowindward.com> 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
> 
> Sounds like all you really want is to save some state, specifically a 
> notification state.
> 
> You just ivar/property/object somewhere that keeps track of the last sent 
> Notification.
> Put it in the most accessible place to each of the observer objects.
> It could simply be a property class NSNotification and it will have 
> everything it had before.
> Just keeps a reference.
> Update the reference as new notifications come.

Yes, but the problem with that is there is 26 of them and they will all be 
storing the same value. What I actually did was to subclass NSOperationCenter 
and add 3 class methods it and overrode postNotificationName and friends.

In the postNotificationName I have save the notification in a dictionary and 
then call super. 

I added:

+(void) enableRememberNotifications;
+(void) repostNotificationName:;
+(void) getNotificationInfoForNotificationName:;

I just call enableRememberNotifications, at App startup and then call 
repostNotificationName whenever I need an update - works a treat!

Thanks for your help
Dave


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to