↧
Answer by Enrico Cupellini for NSArray of weak references...
I think an elegant solution is what Mr. Erik Ralston propose on his Github repositoryhttps://gist.github.com/eralston/8010285this are the essential steps:create a category for NSArray and...
View ArticleAnswer by Ciprian C for NSArray of weak references (__unsafe_unretained) to...
If you use a lot this comportment it's indicated to your own NSMutableArray class (subclass of NSMutableArray) which doesn't increase the retain count.You should have something like...
View ArticleAnswer by Harish Kumar Kailas for NSArray of weak references...
To add weak self reference to NSMutableArray, create a custom class with a weak property as given below.NSMutableArray *array = [NSMutableArray new];Step 1: create a custom class @interface DelegateRef...
View ArticleAnswer by ArtFeel for NSArray of weak references (__unsafe_unretained) to...
The simplest solution:NSMutableArray *array = (__bridge_transfer NSMutableArray *)CFArrayCreateMutable(nil, 0, nil);NSMutableDictionary *dictionary = (__bridge_transfer NSMutableDictionary...
View ArticleAnswer by user187676 for NSArray of weak references (__unsafe_unretained) to...
If you do not require a specific order you could use NSMapTable with special key/value optionsNSPointerFunctionsWeakMemoryUses weak read and write barriers appropriate for ARC or GC. Using...
View ArticleAnswer by Yaniv De Ridder for NSArray of weak references...
I believe the best solution for this is to use NSHashTable or NSMapTable. the Key or/and the Value can be weak. You can read more about it here: http://nshipster.com/nshashtable-and-nsmaptable/
View ArticleAnswer by eug for NSArray of weak references (__unsafe_unretained) to objects...
I've just faced with same problem and found that my before-ARC solution works after converting with ARC as designed.// function allocates mutable set which doesn't retain references.NSMutableSet*...
View ArticleAnswer by Richard Hodges for NSArray of weak references (__unsafe_unretained)...
I am new to objective-C, after 20 years of writing c++. In my view, objective-C is excellent at loosely-coupled messaging, but horrible for data management. Imagine how happy I was to discover that...
View ArticleAnswer by paulmelnikow for NSArray of weak references (__unsafe_unretained)...
If you need zeroing weak references, see this answer for code you can use for a wrapper class.Other answers to that question suggest a block-based wrapper, and ways to automatically remove zeroed...
View ArticleAnswer by Thomas Tempelmann for NSArray of weak references...
The solutions to use a NSValue helper or to create a collection (array, set, dict) object and disable its Retain/Release callbacks are both not 100% failsafe solutions with regard to using ARC.As...
View ArticleAnswer by yuji for NSArray of weak references (__unsafe_unretained) to...
As Jason said, you can't make NSArray store weak references. The easiest way to implement Emile's suggestion of wrapping an object inside another object that stores a weak reference to it is the...
View ArticleAnswer by Jason Coco for NSArray of weak references (__unsafe_unretained) to...
No, that's not correct. Those aren't actually weak references. You can't really store weak references in an array right now. You need to have a mutable array and remove the references when you're done...
View ArticleNSArray of weak references (__unsafe_unretained) to objects under ARC
I need to store weak references to objects in an NSArray, in order to prevent retain cycles. I'm not sure of the proper syntax to use. Is this the correct way?Foo* foo1 = [[Foo alloc] init];Foo* foo2 =...
View Article