Explanation as to why notification is used


#1

Hi,
In zoneChange method it was implemented like this in the book

-(void)zoneChange:(NSNotification *)note;

can someone tell me why the argument is an NSNotification?
Also after searching the method that call zonChange i found out this

Selector that specifies the message the receiver sends notificationObserver to notify it of the notification posting. The method specified by notificationSelector must have one and only one argument (an instance of NSNotification).

But still couldn’t understand the meaning, Can someone pls explain it to me?


#2

[quote=“chanyeechoong”]Hi,
In zoneChange method it was implemented like this in the book

-(void)zoneChange:(NSNotification *)note;

can someone tell me why the argument is an NSNotification?
Also after searching the method that call zonChange i found out this

Selector that specifies the message the receiver sends notificationObserver to notify it of the notification posting. The method specified by notificationSelector must have one and only one argument (an instance of NSNotification).

But still couldn’t understand the meaning, Can someone pls explain it to me?[/quote]

I am not 100% clear on your question but I think you are asking why the zoneChange method is sent an NSNotification. This allows you to examine the notification object the caused the call. I don’t have a use case in mind but perhaps in a more complex program with a number of notifications you may have need to examine the notification when tripped.


#3

thanks that’s what i was asking.


#4

[quote=“C6silver”][quote=“chanyeechoong”]Hi,
In zoneChange method it was implemented like this in the book

-(void)zoneChange:(NSNotification *)note;

can someone tell me why the argument is an NSNotification?
Also after searching the method that call zonChange i found out this

Selector that specifies the message the receiver sends notificationObserver to notify it of the notification posting. The method specified by notificationSelector must have one and only one argument (an instance of NSNotification).

But still couldn’t understand the meaning, Can someone pls explain it to me?[/quote]

I am not 100% clear on your question but I think you are asking why the zoneChange method is sent an NSNotification. This allows you to examine the notification object the caused the call. I don’t have a use case in mind but perhaps in a more complex program with a number of notifications you may have need to examine the notification when tripped.[/quote]

So in other words, you are just logging it in as an event viewer (kinda like Window’s Event Viewer? Having it sent to NSNotification isn’t really necessary but helpful later down the road.

That makes sense.

Thanks!