避免死循环

//self.str = @"sdf";

//NSRunLoop会出现循环引用死循环

for(int i = 0; i<1000000; i++) {

//自动释放池可避免死循环

@autoreleasepool {

NSString*str = @"Abc";

str = [str lowercaseString];

str = [str stringByAppendingString:@"xyz"];

NSLog(@"%@",str);

}

}

inti = 1;

intj = i++;

if((i>j++) && i++ == j) {

i+= j;

}

//求i得值5

NSLog(@"%d",i);

//self打点调用会出现死循环

- (void)setStr:(NSString*)str{

self.str = str;

}

你可能感兴趣的:(避免死循环)