Convert NSRange contents to NSString?
cocoa, macos, nsrange, nsstring
Solution
Code:
NSString *string = @"abcdefgh";
NSRange range;
range.location = 4;
range.length = 4;
NSString *subString = [string substringWithRange:range];
NSLog(@"%@",subString);
Output:
efgh
Problem
I am working on a Cocoa Mac OSX app, and I am wondering if it is possible to present the contents of an `NSRange` found by: ``` NSRange range; range.location = 4; range.length = 4; ``` as an `NSString`? e.g. in the example above, if I had a string with contents "abcdefgh", presenting the contents of the above range as a string would give "efgh". Is this possible?