-2
我寫的會從一個字符串分隔內容的代碼,檢查內容有引號作爲第一個字符,然後將它們合併回兩個字符串: 一個開頭引號和一個沒有的引號。我有以下代碼,但是當我運行它時,它似乎沒有檢測到引號。檢查字符串第一個字符是引號
NSArray *detailTextLabelContentArray = [[NSArray alloc] initWithObjects:@"Some",@"Good",@"Stuff",@"\"Lazy\"", nil];
for (NSInteger index = 0; [detailTextLabelContentArray count] > index; index++)
{
if ([[detailTextLabelContentArray objectAtIndex:index] substringToIndex:1] != @"\"")
{
if (index == 0)
{
detailTextLabelContent = [[detailTextLabelContentArray objectAtIndex:index] substringToIndex:1];
}
else
{
detailTextLabelContent = [NSString stringWithFormat:@"%@; %@",detailTextLabelContent,detailTextLabelContent = [[detailTextLabelContentArray objectAtIndex:index] substringToIndex:1]];
}
}
}
NSLog(detailTextLabelContent);
我在這裏做錯了什麼?