Ready to Level-Up?

This just in! If your rusty iOS skills could use some refining, or if you're just starting out and you want to level-up fast, consider signing up for our upcoming iOS Screencasts

New from iOS Rocket Surgery Swift Video Tutorials: The rapidly evolving Apple-iOS ecosystem has just been thrown into tumult with the recent introduction of the Swift Programming Language. Are you ready to finally try iOS development? Are you needing to switch from Objective-C to Swift? Sign up today for our free video courses!
(By the dear folks at Swift Tutorial Videos, a sister company)

Tuesday, December 17, 2013

How To Check if a NSString Contains Another NSString

So, you want to see if a string includes a given sub-string in iOS, huh?

NSRanges and NSString searches in iOS aren't the most fun thing to work with, fortunately there is a simple way to determine if a String contains another String in iOS, and it goes like this:

  NSString *interestingString = @"In the course of human events...";
  BOOL contains = ([interestingString rangeOfString:@"course"].location != NSNotFound);

Well, thank goodness that you don't need to iterate over matches, but if you do, we wrote about that too. Give us a +1 on Google, and we'll have your answer ready when you need it.

About Me

Easy NSDateFormatter Tool

Save yourself some time in formatting your NSDates to NSStrings, and use the Blind NSDate app, which you can download from iTunes. There's also a website where you can format your NSDates:

Popular Posts

Designed By Seo Blogger Templates