Re: Encoding function pointer in an NSValue
Re: Encoding function pointer in an NSValue
- Subject: Re: Encoding function pointer in an NSValue
- From: Charles Steinman <email@hidden>
- Date: Thu, 24 May 2007 15:11:35 -0700 (PDT)
Neither
is quite right. The value:withObjCType: method takes a pointer to the
value. As it is, you're passing it a pointer to a function, whereas
what you want is a pointer to a function pointer. So it should be:
MyObjectComparitor objComparitor = foo; // some function pointer
[NSValue value:&objComparitor withObjCType:@encode(MyObjectComparitor)];
That ought to work.
Cheers,
Chuck
----- Original Message ----
From: Ken Tozier <email@hidden>
To: Cocoa-Dev Mail <email@hidden>
Sent: Thursday, May 24, 2007 2:06:43 PM
Subject: Encoding function pointer in an NSValue
Hi
I've managed to confuse myself about what exactly I should supply to
NSValue's value:withObjCType: when the value is a function pointer.
Say I define a function pointer typedef like so:
typedef int (*MyObjectComparitor)(id inObject1, id inObject2);
Which of the following is correct?
MyObjectComparitor objComparitor = foo; // some function pointer
NSValue *comparitor = [NSValue value: foo
withObjCType:@encode(MyObjectComparitor)];
NSValue *comparitor = [NSValue value: foo
withObjCType:@encode(MyObjectComparitor *)];
Is it possible to do this sort of thing with a function pointer?
Thanks in advance
Ken
____________________________________________________________________________________Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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