In Javascript you can simply state that you want the first three characters of a string like so:
However, in Objective-C I can't find such an easy way to do this. I can accomplish the same with the following:
But does anyone know of an approach in objective-c or c that is as simple or equivalent as the javascript example above?
Further; how would get the first three characters from the following string in Objective-C, easily?
Code:
console.log(@"IAmRobertNash".substring(0,3));
However, in Objective-C I can't find such an easy way to do this. I can accomplish the same with the following:
Code:
NSString *string = @"IAmRobertNash";
NSRange range = [string rangeOfString:@"Ro"];
NSLog(@"%@", [string substringToIndex:range.location]);
But does anyone know of an approach in objective-c or c that is as simple or equivalent as the javascript example above?
Further; how would get the first three characters from the following string in Objective-C, easily?
Code:
@"IAmRobertNashRobertNash"