Tuesday 30 April 2013

What is NSRange?

NSRange is a C Struct,  it used to specify sub-ranges inside strings and arrays.

typedef struct {

  NSUInteger  location;
  NSUInteger lenght;

} NSRange;

Important location value is "NSNotFound".

NSString *myString = @"Hi Every One!" ;
NSString *search = @"Hello";

NSRange range = [greeting rangeOfString:search];

if (range.location == NSNotFound) {

// could not find search in myString

}

written by: infinitywebseo  

No comments:

Post a Comment