NSValue *value = [NSValue valueWithNonretainedObjectValue:myObj]; [array addObject:value]; and when you get the object: value = [array objectAtIndex:x]; myObj = [value nonretainedObjectValue];
一个weak引用NSArray的实现
最新推荐文章于 2022-07-30 17:50:09 发布
NSValue *value = [NSValue valueWithNonretainedObjectValue:myObj]; [array addObject:value]; and when you get the object: value = [array objectAtIndex:x]; myObj = [value nonretainedObjectValue];