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: 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.