Ken thank you.

the problem was elsewhere in a dictionary key name...
thank you for your help!!!

Sandro Noel.

On 9-Jan-09, at 2:09 AM, Ken Thomases wrote:

On Jan 8, 2009, at 7:57 PM, Sandro Noel wrote:

I have this callback from DiskArbritation framework
and I would like to send a notification to my app.
but it does not seem to work.
Does not seem to work in what way?  Are you getting compiler errors  
or warnings?  Crashes at runtime?  What?

the callback is defined like this.
void DiskDisappearedCallback(DADiskRef disk, void *context){
        CFDictionaryRef diskDescription = DADiskCopyDescription(disk);
        NSDictionary *nsDiskDescription = (NSDictionary *)diskDescription;
        
        NSString *name = [nsDiskDescription valueForKey:@"DAVolumeName"];
        NSString *type = [nsDiskDescription valueForKey:@"DAVolumeKind"];
        NSString *path = [nsDiskDescription valueForKey:@"DAVolumePath"];     

[[NSNotificationCenter defaultCenter] postNotificationName:ADD_REMOVE_NOTIFICATION object:nil userInfo:nil];
}

Obviously, default center does not exist in the callback,
Actually, I don't know what you mean here, so it's far from obvious.

The default notification center is a singleton. It always "exists" in the sense that you can always retrieve it using [NSNotificationCenter defaultCenter], just as you have.

but i cant seem to typecast the context to
my object type and retrieve the notification center from the object. i just do not know how to do it.
Well, since the default notification center is a singleton, it is  
effectively globally available.  You don't need to stash a reference  
to it in your object and retrieve it from there.
With regard to the general question of how you can message the  
object passed in context: given that the context is an object  
pointer, you can just cast it:
        id myObject = (id)context;
        [myObject someMethod:someArgument];

If you have a more specific type than id, go ahead and use that.

Regards,
Ken

_______________________________________________

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

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

Reply via email to