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

1

u/[deleted] Jun 02 '14

How old is this blog post?

  • Interface holds instance variables;

  • No storyboarding;

  • UIViewController initialisation with simple init;

  • Label uses autoresizing mask instead of constraints;

  • Anything else i've missed?

3

u/sobri909 Jun 02 '14

Interface holds instance variables;

There's nothing wrong with using ivars if you have no need for setters and getters. They're not deprecated, and have many perfectly valid uses.

No storyboarding;

Storyboards have been fairly universally panned as a tool for apps of any reasonable size. They're a great idea, but they don't scale, and the tools provided are still weak and will ultimately slow you down more than they help you out.

UIViewController initialisation with simple init;

Nothing wrong with this. If you can't call init on a class and get something usable, it's not built right.

Label uses autoresizing mask instead of constraints;

In our projects we still don't use Auto Layout. It offers us nothing we haven't already got, and comes with a large amount of baggage. It's over engineered, and only suitable for extreme cases. Eventually everyone's going to realise this, and drop it like it's XML in a JSON world.

2

u/[deleted] Jun 02 '14

They're not deprecated, and have many perfectly valid uses.

They do have a valid use if they are not in public interface. In OP's case - ivars are bleeding implementation details which breaks OOP

My point about storyboarding is that it provides a mechanism of passing data between view controllers in any direction. And in case of "going backwards" - through any amount of segues (unwinding). Thus OP reinvents the wheel. And poorly for that matter as well, since UINavigationControllerDelegate provides delegate methods to implement for tracking pushing and popping of its child view controllers;

I will a agree on you with Auto-Layout over-engineering (still dropping it like XML would be bold claim), however op at least could use xib to create UILabel instead of making everything in code. After all - he did use init method which should call the designated initWithNibName:bundle: initialiser.

1

u/sobri909 Jun 03 '14

Yeah I'm being overly hopeful about Auto Layout getting eventually dropped. I suspect it's here to stay, which disappoints me greatly.