Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

iOS Passing Data Between View Controllers Technique 1

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
1,662
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Nov 2, 2011

This video discusses one of the most basic techniques for passing data between view controllers in an iOS application. This technique uses storing a local iVar in one class and passing it to the second class about to be displayed on the screen.

Although this is a very simple example using an NSString, it can be applied using any other type of data as well - whether it be a collection or a custom data model object.

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (Nethfel)

  • hey man thans for the tutorial, very straight forward and easy to assimilate. I'm new to xcode and notice that the syntax that you used in this tutorial doesn't work quite well with the new xcode sdk. So, I had to make some changes in onder to get it done.

    Best,

  • @ismalakazel No problem - yeah, XCode 4.2 is different from XCode 4, although it is possible to make the app pretty much identically one might have to make minor modifications. This is especially true if someone uses storyboards which has other ways of making it possible to get the destination view controller.

  • Thank you for this video, Nethfel! However, I tried to make same thing SDK iOS 5 version and it doesn't work. I checked all connections on storyboard, typo, and etc. Do I need to add some extra codes because of "storyboard"?

  • @katsushi11 If you are using storyboards, the passing data technique is different - but only by a little. You'll want to implement: -(void)prepareForSegue:(UIStor­yboardSegue *)segue sender:(id)sender. The segue object contains a reference to the destination view controller (as well as an identifier that you set in IB) to identify which view your transitioning to (should you have multiple separate views you connect to). With the destination view controller, you can then pass the data.

  • @Nethfel The technique I showed is geared for if you use nibs instead of storyboards.

  • This is a complete unit, there is no need for a part two on this one. I will be doing another one using singletons, but I haven't had the opportunity yet. I hope to soon when I have my laptop back.

see all

All Comments (8)

Sign In or Sign Up now to post a comment!
  • I found this video to be very useful, I would love to see some followup videos that elaborate on the other methods you alluded to!

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more