I have a class which must initialize a group of similar objects the same way.
NSNumber *a = nil;
NSNumber *b = nil;
NSNumber *c = nil;
a, b and c are member variables of an existing object. In my code I use a more complex NSObject subclass, but this example is easier to understand using NSNumbers.
All 3 objects must be initialized in a similar way. Therefore I want to build an array of pointers which I can use within a for-loop like this:
NSPointerArray *objs = [NSPointerArray weakObjectsPointerArray];
[objs addPointer:&a];
[objs addPointer:&b];
[objs addPointer:&c];
Running the above code I get the following error:
error: address doesn't contain a section that points to a section in a object file
How can I build an array which I can explore with a loop like this?
for (id *o in objs) {
*o = @2;
}
NSPointerArray.