• 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: "James Winetke" <email@hidden>
  • Date: Wed, 19 Jun 2002 20:13:48 +0000

On Wed, Jun 19, 2002 at 01:42:04PM -0600, Carl Jochen Norum wrote:

Try:

[myArray addObject:&aRange];

That generates a warning for "incompatible pointer type", presumably
because NSMutableArray knows that NSRange is a struct type.

I wondered why this should matter (as long as it's a pointer, and NSArrays
store pointers), but John Anderson's comment about plain C types not
interacting with Cocoa memory management provided a hint.

Luc Heinrich, Philip Morelock, Itrat Khan and Don Briggs quickly suggested
an analogue of the int-to-NSNumber strategy, and Luc points out that
ranges can be cleanly stored in an NSValue (using valueWithRange and
rangeValue) as well as a string (using NSStringFromRange and
NSRangeFromString). NSValue in particular is a useful little bugger,
expressly designed for my collection problem, which I had failed to see.

Thanks very much for the help.

Jim

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx
_______________________________________________
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.
  • Prev by Date: Re: Can't cram an NSRange into an NSArray?
  • Next by Date: [Q] large flat files usage
  • 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