I know this question was already asked in the past, but i am really confused and can’t get out of it.
i have got 9 pointers to IB objects declared like:
IBOutlet UIButton *but1;
IBOutlet UIButton *but2;
….
NSMutableArray *buttons;
declared properties:
@property (nonatomic,retain) IBOutlet UIButton *but1;
@property …..
in IB i have made the connections from buttons to pointers.
I need now to fill the array buttons with these pointers to run UIButton methods like
[[buttons objectWithId:0] setImage:[UIImage imageNamed:@"image1.png"]];
I know i can’t fill arrays with pointers, is there some way to get IBOutlets into arrays?
Your overthinking the problem. By default, all references to all objects are pointers.
This:
… defines a pointer.
Therefore, all default operations with objects use pointers. You usually don’t even have to think about it. To add a pointer to a UIButton to a NSMutableArray just use (note the
selfnotation):The IBOutlet designation has not effect on references in code. It is just there so Interface Builder can parse source and figure out which properties is supposed pay attention to. Otherwise, it does nothing and you can ignore it.
Of course, I have to ask: Why are you putting buttons that are already named properties into an array?
Instead of this:
… why not just do this?
There’s not much sense in using named properties if you don’t use the names as the primary reference.