Objective-C: trimming whitespace
-
30-09-2019 - |
Pergunta
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]];
Solução
Try to make a copy of the array objects: NSString *thisXStr = [NSString stringWithString:[thisSetArray objectAtIndex:0]]; ...
Outras dicas
Crap, never mind, stupid syntax error on a NSLog...
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow