我用下面的代碼:分配錯誤NSString?
for (int i=1; i<=3;i++){
NSString *theString = [[NSString alloc] initWithFormat:@"%i",imageValue];
theString = [theString stringByAppendingFormat:@"%i.jpg",i];
[img addObject:theString];
NSLog(@"the string %@:",theString); //01.jpg ,02.jpg and 03.jpg
[theString release];
}
,但我得到這個錯誤3次,爲什麼?
錯誤:
myapp(15467,0xacdaa2c0) malloc: *** error for object 0x4eb1ca0: pointer being freed was not allocated