私はiPhone開発の初心者で、xcodeで非常に奇妙な問題を抱えています。何らかの理由で、文字列の末尾に末尾の空白をランダムに追加しています。私の最初の文字列値は xml から解析され、そこから文字列の最後のセクションを取得しようとします。このランダムな空白のために、これは困難であることが証明されています。どんな助けでも大歓迎です。
マイコード
//initial String
<title>March 15 2013 Metals Commentary: Thomas Vitiello</title>
//Parsing
NSString *name = [[stories objectAtIndex: storyIndex] objectForKey: @"title"];
NSLog(@"myname: %@ %i", name, name.length);
//Log at this point
myname: March 15 PM Metals Commentary: Thomas Vitiello
59
//Attempt at Removing Whitespace
NSArray *lastName=[name componentsSeparatedByString:@" "];
name = [[lastName objectAtIndex:6]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSLog(@"myname: %@ %i", name, name.length);
//Log at this point
myname: Vitiello
9 //<--Should be 8, not 9. This annoying whitespace is also particularly long, taking more than 1 character space, despite obviously being 1 character long.