• 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: Shawn Erickson <email@hidden>
  • Date: Mon, 1 Jul 2002 20:01:56 -0700

On Monday, July 1, 2002, at 07:05 PM, James Winetke wrote:

I have a followup question. CFStringCreateArrayWithFindResults() returns
a CFArray filled with CFRange structures, which works great; I can see
the ranges in the debugger and they're perfect.

CFArrays stores pointer sized elements that usually are true pointers to c-structs of some type. In this case CFRanges. So the array doesn't contain the structures just pointers to them.

I can't figure out how to get the ranges out of the array. The compiler
balks with "incompatible types in assignment" when I try things like
this:

CFRange myRange;
CFArrayRef thisArray

thisArray = CFStringCreateArrayWithFindResults(...);
myRange = CFArrayGetValueAtIndex(thisArray, (CFIndex) 0);

[snip]

CFArrayGetValueAtIndex returns a (void*) that you are trying to stick into a CFRange which is a structure. You need to do two things...

CFRange* myRange;
...

myRange = (CFRange*) CFArrayGetValueAtIndex(...);

... myRange->location ...
... myRange->length ...

Or you can cast it to NSRange.

-Shawn
_______________________________________________
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: "James Winetke" <email@hidden>)

  • Prev by Date: [NSApp mainWindow] weirdness
  • Next by Date: Re: [NSApp mainWindow] weirdness
  • Previous by thread: Re: Can't cram an NSRange into an NSArray?
  • Next by thread: Re: RFC: Allocating via a protocol/interface
  • Index(es):
    • Date
    • Thread