NSMutableArray *lplp = [[NSMutableArray alloc] init];
NSMutableArray *lplp2 = [[NSMutableArray alloc] init];
NSLog(@"1 %d",[lplp retainCount]); //0
UIImageView *dd=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1.jpeg"]];
NSLog(@"2 %d",[dd retainCount]); //1
[lplp addObject:dd];
NSLog(@"3 %d",[dd retainCount]);
[lplp2 addObject:dd];
NSLog(@"4 %d",[dd retainCount]);
NSString *fileLocation = [[NSBundle mainBundle] pathForResource:@"2" ofType:@"png"];
NSData *imageData = [NSData dataWithContentsOfFile:fileLocation];
一直對objective c的reference counting參考模式很不習慣
留言