Created
December 12, 2013 13:58
-
-
Save marcinmatczuk/7928339 to your computer and use it in GitHub Desktop.
A potential replacement for NSHashTable for iOS 5 - need to test it and see how it works with ARC.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Source: http://stackoverflow.com/questions/4692161/non-retaining-array-for-delegates/4692229#4692229 */ | |
@implementation NSMutableArray (WeakReferences) | |
+ (id)mutableArrayUsingWeakReferences | |
{ | |
return [self mutableArrayUsingWeakReferencesWithCapacity:0]; | |
} | |
+ (id)mutableArrayUsingWeakReferencesWithCapacity:(NSUInteger)capacity { | |
CFArrayCallBacks callbacks = {0, NULL, NULL, CFCopyDescription, CFEqual}; | |
// We create a weak reference array | |
return (id)(CFArrayCreateMutable(0, capacity, &callbacks)); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment