Re: Adding methods to NSString
Re: Adding methods to NSString
- Subject: Re: Adding methods to NSString
- From: Frank <email@hidden>
- Date: Thu, 27 Nov 2003 10:28:04 +0100
Thanks for the reply.
Actually my method uses the rangeOfString: method. I just wrap it in a
more conveniant form which returns a bool instead of a NSRange.
Do you have any idea why adding the following method does not work
(compiles but results in method not found):
@interface NSString ( StringSearch )
-(bool) containsString: (NSString *) string;
@end
@implementation NSString
-(bool) containsString: (NSString *) string
{
NSRange result;
result = [self rangeOfString: string options: NSCaseInsensitiveSearch];
return (result.location != NSNotFound);
}
RESULT:
*** -[NSCFString containsString:]: selector not recognized
Best Regards,
Frank
On 2003, Nov 27, , at 10:13, Nick Zitzmann wrote:
>
>
On Nov 26, 2003, at 2:53 PM, Frank wrote:
>
>
> I tried adding a category to NSString class to add a method which
>
> check if one string is contained within another (like contains
>
> statement in applescript).
>
>
There already are such methods - NSString's -rangeOfString: methods.
>
>
> Problem is that the NSString object complains it doesn't recongnize
>
> the selector. Also the NSString object presents itself as being of
>
> the NSCFString class, which I believe is the problem. As I cannot
>
> find any reference to the NSCFString class (header files?) I cannot
>
> add a category to it.
>
>
NSString is a class cluster, and NSCFString is one of its private
>
subclasses. You don't need to worry about them, as they are managed by
>
the NSString class.
>
>
Nick Zitzmann
>
AIM/iChat: dragonsdontsleep
>
Check out my software page: http://seiryu.home.comcast.net/
>
S/MIME signature available upon request
>
>
"That's a funny thing to promise. Well, you can't never let anything
>
happen to him [Nemo]; then, nothing would ever happen to him." - Dory,
>
from the movie "Finding Nemo"
_______________________________________________
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.