Re: What can I do with an NSRange in Objective-C?
Re: What can I do with an NSRange in Objective-C?
- Subject: Re: What can I do with an NSRange in Objective-C?
- From: email@hidden
- Date: Sun, 8 Feb 2004 17:57:01 -0500 (EST)
I dont know what the old fashioned way is, but the way you can use NSRange
is varied and quite helpful in many cases, such as rangeOfString
NSRange aRange = [someString rangeOfString:@"The String"];
if(aRange.length){
// Do stuff
}
or use the location
int loc = aRange.location;
I am sans books and reference at the moment, forgive misgiven syntax
April
>
Hi,
>
>
I want to use the method -rangeOfCharacterFromSet on an NSString*.
>
Unfortunately, this method returns an NSRange, and there seems to be very
>
few methods in the NSRange API for Objective-C. In particular, there are
>
no
>
accessor methods. The only thing I can find to do with this NSRange is to
>
convert it to a string using NSStringFromRange (which is an "Objective-C
>
Classic" function), and then parse the string to get the "range" and
>
"length" integers. That would be quite a kludge!
>
>
Look at the left frame in here and you'll see NSRange API listed for Java,
>
but none for Objective-C.
>
>
http://developer.apple.com/documentation/Cocoa/Conceptual/GeometryandRange/i
>
ndex.html#//apple_ref/doc/uid/10000046i
>
>
Am I missing something?
>
>
I do find this declaration:
>
>
typedef struct _NSRange {unsigned int location; unsigned int length;}
>
NSRange;
>
>
Can I dig into this struct and access those two ints the old-fashioned
>
way?
>
>
Jerry Krinock
>
San Jose, CA USA
>
_______________________________________________
>
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.
_______________________________________________
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.