When I hard code the string in question and attempt to substringWithRange, it works just fine. But when I take a user input as a char and cast it to NSString, it throws up an NSRange exception. Is it because I am casting a char?
This doesn't work:
char word[30];
NSString *otherWord = [NSString stringWithFormat:@"%s", word];
scanf("%s", word);
NSString *firstCharacter = [otherWord substringWithRange:NSMakeRange(0, 3)];
However, this one does:
char word[30];
NSString *otherWord = @"SomeString";
scanf("%s", word);
NSString *firstCharacter = [otherWord substringWithRange:NSMakeRange(0, 3)];
I also checked to make sure that "otherWord" has the proper value, which it does.
Any suggestions?