What does NSMakeRange (i, 1) mean?

I'm just starting to learn iOS.
What does " NSMakeRange(i, 1) " mean?

 for (int i = 0; i < [name length]; i++) { NSRange range = NSMakeRange(i, 1); NSString *subString = [name substringWithRange:range]; const char *cString = [subString UTF8String]; if (strlen(cString) != 3) { return NO; } } 
+8
ios objective-c cocoa-touch
source share
2 answers

NSMakeRange(i, 1) creates a range with location i and length 1 . See the documentation for NSMakeRange and NSString substringWithRange for further information and related functions.

+9
source share

Alt -click the function name in Xcode, you will get a link. The function creates a range starting with i and having a length of 1. In essence, you select individual characters from a string.

+9
source share

All Articles