我正在創建一些代碼,它將在字符之間找到空格,並在空格之前和空格之後使用字符。這些字符存儲在NSString中。這是我到目前爲止,但是,它沒有看到空的字符。Objective-C中的空字符
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
,空字符串( 「」)和 「」,但無濟於事。有任何想法嗎?
'indexOfSpace == count;'包含一個雙等號。你是否認爲這是一個等號? – cmptrgeekken
哎呀,我沒有嘿嘿。謝謝! – skylerl