我正在创建一些代码,它将在字符之间找到一个空格,并使用空格之前的字符和空格之后的字符。这些字符存储在一个 NSString 中。这是我到目前为止所拥有的,但是,它没有看到空字符。
NSString *tempTitle = self.title;
unsigned int indexOfSpace; // Holds the index of the character with the space
unsigned int titleLength = (unsigned int)self.title.length; // Holds the length of the title
for (unsigned int count = 0; count < titleLength; count++)
{
if ([tempTitle characterAtIndex:count] == "") // If the character at the index is blank, store this and stop
{
indexOfSpace == count;
}
else // Else, we keep on rollin'
{
NSLog(@"We're on character: %c", [tempTitle characterAtIndex:count]);
}
}
我试过了nil
,空字符串(“”)和“”但无济于事。有任何想法吗?