Reputation: 9672
I've found discussion of dealing with a single IBOutlet and multiple objects but what about the reverse? I have a single object I want to assign multiple IBOutlets to, are there any pitfalls there especially around releasing the IBOutlets in dealloc/viewDidUnload?
EDIT: For example...
I have a ViewController class that uses a different XIB for iPad and iPhone (its a custom CameraView controller). Now on the iPhone there are 2 different labels for zoomLevel and videoDuration, on the iPad I use the same label for both, so in the iPad XIB I'd like to point the two IBOutlets to the same UILabel.
Upvotes: 1
Views: 333
Reputation: 2409
I believe each outlet assigned to the object would raise the retain count by 1, and as you set the outlets to nil when the view unloads the count would be decremented by 1 each time, so it should work
Since you have to reinitialize properties each time the view is displayed I would say a pitfall is the view display logic has been removed from the XIB and put into your code. I would say the severity of this is subject to personal opinion and how religious you want to maintain the MVC relationship.
Upvotes: 1