在线上获得断点/崩溃
if ([[status objectAtIndex:i] isEqualToString:(@"VM running")])
不知道为什么,也许我做错了?
NSMutableArray *status = [dictValue valueForKeyPath:@"VM_LIST.SERVER_STATUS_MSG"];
NSLog(@"%@", status);
int i = 0;
NSLog(@"%@", [status objectAtIndex:i]);
while (i <= [status count])
{
if ([[status objectAtIndex:i] isEqualToString:(@"VM running")])
{
[statuses addObject:@"check.png"];
}
else
[statuses addObject:@"x.png"];
i++;
}
NSLog
状态为:
(
"VM running",
"VM running",
"VM running"
)
答案 0 :(得分:1)
我注意到一些奇怪的事情:
if ([[status objectAtIndex:i] isEqualToString:(@"VM running")])
不应该没有()的:
if ([[status objectAtIndex:i] isEqualToString:@"VM running"])
这似乎太过分了(超出范围):
while (i <= [status count])
我认为应该是:
while (i < [status count])
甚至更好,只有最安全的方式:
for (NSString *statusString in status) {
if ([statusString isEqualToString:@"VM running"]) {