Re: Can't cram an NSRange into an NSArray?
Re: Can't cram an NSRange into an NSArray?
- Subject: Re: Can't cram an NSRange into an NSArray?
- From: Douglas Davidson <email@hidden>
- Date: Wed, 19 Jun 2002 13:17:54 -0700
On Wednesday, June 19, 2002, at 12:51 PM, Phillip Morelock wrote:
With ints I can wrap them in an NSNumber at some unknown cost in
performance, but with NSRanges I'm sort of stuck.
You can do the same thing here. My idea comes from a "Java" way of
thinking, so forgive me, but couldn't you just create an "inner class"
and
store NSRanges in instances of that class, storing the instances in the
Array?
Lots of suggestions, but as it happens the kit has already provided a
solution--and it's in NSRange.h.
@interface NSValue (NSValueRangeExtensions)
+ (NSValue *)valueWithRange:(NSRange)range;
- (NSRange)rangeValue;
@end
So you can use [NSValue valueWithRange:myRange] to wrap ranges in
NSValues, and [value rangeValue] to unwrap them.
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.