• 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: Can't cram an NSRange into an NSArray?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: Can't cram an NSRange into an NSArray? (From: Phillip Morelock <email@hidden>)

  • Prev by Date: Re: Can't cram an NSRange into an NSArray?
  • Next by Date: Re: Can't cram an NSRange into an NSArray?
  • Previous by thread: Re: Can't cram an NSRange into an NSArray?
  • Next by thread: Re: Can't cram an NSRange into an NSArray?
  • Index(es):
    • Date
    • Thread