discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Searching NSString


From: Adam Fedor
Subject: Re: Searching NSString
Date: Tue, 1 May 2007 12:31:21 -0600


On May 1, 2007, at 11:38 AM, Sašo Kiselkov wrote:

BOOL ContainsString (NSString *string, NSString *keyword)
{
  return [string rangeOfString: keyword].location != NSNotFound;
}

Slightly better:

BOOL ContainsString (NSString *string, NSString *keyword)
{
return (string != NULL) && ([string rangeOfString: keyword].location != NSNotFound);
}

as OSs like Solaris will crash if you try to treat a NULL pointer as a structure.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]