I'm an experienced iOS dev and I have decided to try my hand at some AppKit development. There are a couple of adjustments that I am making API-wise, but otherwise am finding OS X development to be, shall we say, 'familiar'.
I've been building my AppKit UIs in Interface Builder and noticed that when I use the WYSIWYG editor to create properties in my code files, Apple is creating the following:
@property (assign) IBOutlet NSTableView *tableView;
I find this very curious because the default way of doing things in iOS would have led me to do this:
@property (nonatomic, retain) IBOutlet NSTableView *tableView;
I realize that in Mac development I don't have the same memory constraints that I do on mobile, where a view could get unloaded and there may be a need for strong references to UI elements.
In the AppKit case I can pretty well assume that my UI elements will always be there unless I fiddle with the view hierarchy and remove it from its parent view. It would seem prudent to have a strong reference at all times in order to guard against unintentionally accessing dangling pointers.
Why is Apple creating a weak reference here, instead of a strong one?
Am I setting myself up for some unintended consequence by using strong references (but properly releasing in dealloc
)? Is there some pattern here that I am missing?