r/iOSProgramming • • Jun 02 '14

Passing Data Between View Controllers

http://www.infragistics.com/community/blogs/torrey-betts/archive/2014/05/29/passing-data-between-view-controllers-ios-obj-c.aspx
1 Upvotes

11 comments sorted by

View all comments

2

u/eaz135 Jun 02 '14

You would generally be passing model objects around in an MVC setup. For eg if you had an IGArticle object and an IGArticleViewController you may have an init method - (id)initWithArticle:(IGArticle *)article. Simply exposing properties can make it a bit confusing on how to consume your controller. Are these properties required to be set? What happens if I don't set this property, will things break?

Having said that exposing readwrite properties is fine when their purpose and usage is documented in the interface and sensible defaults are set.

If multiple parties are interested in a particular object then registering to KVO to observe changes is a better option than slinging the values around various controllers as things change.