discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Searching NSString


From: Sašo Kiselkov
Subject: Re: Searching NSString
Date: Tue, 01 May 2007 19:38:03 +0200
User-agent: Thunderbird 1.5.0.10 (X11/20070306)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

Daniel J Farrell wrote:
> Hello,
> 
> What is the easiest way to search the contents of an NSString for the
> occurrence of a word?
> 
> For example, if I have @"GNUStep is really cool", how can I find out if
> this contains the string @"cool"? I just need a BOOL to be returned.
> 
> I tried looked into this but got a bit hung up on NSPredicate class. It
> seemed to be getting a little too complicated for what I want to do.
> 
> Cheers,
> 
> Dan.

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

- --
Saso
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGN3r7akxhuWWzY78RA97SAKCPIfCTqxlHSXUyhiIBMGvKSSyJ1QCcCfAU
Ir5T3qu4r1Pz7MZU7vmBqnI=
=AYik
-----END PGP SIGNATURE-----




reply via email to

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