【发布时间】:2012-12-19 14:21:14
【问题描述】:
我写了一个代码,它将内容从一个字符串中分离出来,检查内容是否有引号作为第一个字符,然后将它们组合成两个字符串: 一个以引号开头,一个不带引号。我有以下代码,但是当我运行它时,它似乎没有检测到引号。
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);
我在这里做错了吗?
【问题讨论】:
标签: iphone xcode cocoa-touch ios6 nsstring