Reputation: 565
Let's say I want to create a lot of custom buttons with the same UIImage named X. Programmatically, I would create only one UIImage and add this to all the buttons I created. I was wondering if I created these buttons in Interface Builder would IB create only 1 UIImage X or a new UIImage X for each button? Thanks
Upvotes: 2
Views: 96
Reputation: 23438
UIImages are pooled, so repeated calls to [UIImage imageNamed:]
with the same name will actually return the same UIImage
instance. This should apply to objects baked into a NIB as well. Should be easy to verify, though - just print out the pointer value using
NSLog(@"%p", [button imageForState:UIControlStateNormal]);
or whatever for each button in question.
Upvotes: 2