I have been battling with passing data between two view controllers for a couple of days now and getting very confused. I'm new to Objective-C and finding some parts tricky to get my head round.
I have a Navigation Controller, FirstView is a form and on this form I have a button which loads SecondView which contains a TableView for the user to select some options. I then want to pass the selection back to the FirstView controller and display the data etc...
I have read alot about this (stackoverflow, iphonedevsdk, CS 193P Resources) and the options i've seen are,
1) ivar in app delegate (dirty and not recommended)
2) create a singleton
3) create a data model class
4) Use protocols and delegates (recommended by apple)
I want to do things right and want to use option 4 - Delegates in my program
Problem is, I don't understand delegates and how to setup and implement them.
Could anyone provide a basic example on how to setup and pass an NSArray using the delegate and 2 view controllers.
Thanks in advance
Matt
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…