Posted By

iloveitaly on 08/01/09


Tagged

cocoa index String objc nsstring substring contains objectivec found hasprefix


Versions (?)

NSString Contains String Additions


 / Published in: Objective C
 

  1. @interface NSString (SearchingAdditions)
  2.  
  3. - (BOOL) containsString:(NSString *)aString;
  4. - (BOOL) containsString:(NSString *)aString ignoringCase:(BOOL)flag;
  5.  
  6. @end
  7. @implementation NSString (SearchingAdditions)
  8.  
  9. - (BOOL)containsString:(NSString *)aString {
  10. return [self containsString:aString ignoringCase:NO];
  11. }
  12.  
  13. - (BOOL)containsString:(NSString *)aString ignoringCase:(BOOL)flag {
  14. unsigned mask = (flag ? NSCaseInsensitiveSearch : 0);
  15. return [self rangeOfString:aString options:mask].length > 0;
  16. }
  17.  
  18. @end

Report this snippet  

You need to login to post a comment.