Does NSPointerArray support zeroing weak references under ARC? The test below seems to indicate that it does - though this is the sort of thing I often get wrong.
Note that a NULL survives -compact. Presumably the method is free to not compact in trivial cases - or is there another explanation? int main(int argc, const char * argv[]) { NSPointerArray *parray = [NSPointerArray weakObjectsPointerArray]; NSString *value1 = [NSString stringWithUTF8String:"test1"]; [parray addPointer:(__bridge void *)(value1)]; @autoreleasepool { NSString *value2 = [NSString stringWithUTF8String:"test2"]; [parray addPointer:(__bridge void *)(value2)]; for (id item in parray) NSLog(@"%@", item); NSLog(@"Draining pool..."); } for (id item in parray) NSLog(@"%@", item); NSLog(@"Compacting..."); [parray compact]; for (id item in parray) NSLog(@"%@", item); return 0; } output: 2014-08-08 17:41:54.982 WeakObjectsPointerArray[22437:303] test1 2014-08-08 17:41:54.984 WeakObjectsPointerArray[22437:303] test2 2014-08-08 17:41:54.985 WeakObjectsPointerArray[22437:303] Draining pool... 2014-08-08 17:41:54.985 WeakObjectsPointerArray[22437:303] test1 2014-08-08 17:41:54.986 WeakObjectsPointerArray[22437:303] (null) 2014-08-08 17:41:54.986 WeakObjectsPointerArray[22437:303] Compacting... 2014-08-08 17:41:54.986 WeakObjectsPointerArray[22437:303] test1 2014-08-08 17:41:54.987 WeakObjectsPointerArray[22437:303] (null) Thanks Jonathan _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com