Objective-C: trimming whitespace
-
30-09-2019 - |
Question
I have to be missing something. I'm trying to trim the data being pulled from an array but my app crashes on the trim method.
//pull values
NSString* thisXStr = [thisSetArray objectAtIndex:0];
NSString* thisYStr = [thisSetArray objectAtIndex:1];
//cleaning up all the white space
NSString *thisXStrTrim = [thisXStr stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *thisYStrTrim = [thisYStr stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
Solution
Try to make a copy of the array objects: NSString *thisXStr = [NSString stringWithString:[thisSetArray objectAtIndex:0]]; ...
OTHER TIPS
Crap, never mind, stupid syntax error on a NSLog...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow