Re: Placing NSComparator into Dictionary
Re: Placing NSComparator into Dictionary
- Subject: Re: Placing NSComparator into Dictionary
- From: Jens Alfke <email@hidden>
- Date: Fri, 01 Jul 2011 10:29:16 -0700
On Jul 1, 2011, at 5:50 AM, Appa Rao Mulpuri wrote:
> Is there any way to put the NSComparator pointers into Dictionary? I have
> tried put NSValue using [NSValue valueWithPointer:] , but giving me nil in
> get operation.
An NSComparator is a type of block, and blocks can be directly used as Objective-C objects. The only thing is that you have to copy the block first, if you’re going to use it after the containing function exits. So:
NSComparator cCopy = [comparator copy];
[myDict setObject: cCopy forKey: @“comparator”];
[cCopy release];
—Jens_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden