• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Encoding function pointer in an NSValue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Encoding function pointer in an NSValue


  • Subject: Re: Encoding function pointer in an NSValue
  • From: Ken Tozier <email@hidden>
  • Date: Thu, 24 May 2007 18:35:54 -0400

Thanks Joshua and Charles

The next question would be: What happens to the function pointer when the wrapping value is deallocated? Wouldn't want it to invalidate the function pointer. The documentation for NSValue and "Number and Value Programming Topics for Cocoa" doesn't seem to say.

Ken


On May 24, 2007, at 6:14 PM, Joshua Pennington wrote:

You can use:

NSValue *value = [NSValue valueWithPointer:foo];

Which is equivalent to calling:

[NSValue value:foo withObjCType:@encode(void *)];

On 5/24/07, Ken Tozier <email@hidden> wrote:
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



_______________________________________________

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:
email@hidden


This email sent to email@hidden


_______________________________________________

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


  • Follow-Ups:
    • Re: Encoding function pointer in an NSValue
      • From: "Joshua Pennington" <email@hidden>
References: 
 >Encoding function pointer in an NSValue (From: Ken Tozier <email@hidden>)
 >Re: Encoding function pointer in an NSValue (From: "Joshua Pennington" <email@hidden>)

  • Prev by Date: Re: abstract class
  • Next by Date: Re: Cocoa Intermediate Project Ideas
  • Previous by thread: Re: Encoding function pointer in an NSValue
  • Next by thread: Re: Encoding function pointer in an NSValue
  • Index(es):
    • Date
    • Thread