Cast value from NSNotification object
1 answer
The documentation of the class that sent this notification should contain information about what type of notification it is and what it is sending in its object.
You can access the object posted using the method object
:
ClassOfObjectSent *obj = [notification_you_have_received object];
Note that this is a pointer to an object, not a scalar value. If an object NSNumber
, you can get it int
like this:
int i = [obj intValue];
If it's a NSString
, you can use it directly, or - safer - create your own copy (if you are using Cocoa Tap or create a non-GC Mac app you will have to release
copy).
NSString *txt = [obj copy];
+3
a source to share