0

We would like to use two view controllers one for portrait(tableview) and another for landscape(mapview).

We can use protocol/delegate technique to share data between different orientations. The same data will be displayed in tableview or map view based on device orientation

Kindly suggest different techniques to share data between view controllers for orientation changes.

user2613441
  • 169
  • 2
  • 7
  • 1
    possible duplicate of [Passing Data between View Controllers](http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers) – Mick MacCallum Jan 08 '14 at 12:10
  • the views orientation plays no role in the end goal of passing data between viewControllers. The question of how to pass data between viewControllers as commented above, has been asked 100's of times. Please try to do some level of research before asking questions – Simon McLoughlin Jan 08 '14 at 13:04

3 Answers3

1

You should separate model from view. I would also suggest to have a base ViewController with interface to deal with data (it could also have the common properties/ivars). In that base view controller you could handle with modifying/retrieving data. From that base controller the other two will inherit part of implementation as well as the interface. This would help you avoid with code duplication and you could provide a nice interface (even defined by your own protocol). Further changes will be easier to adopt :)

Julian
  • 9,299
  • 5
  • 48
  • 65
0

Use a separate Controller-- a ViewController class or an NSObject class that can act as a main Controller for the two ViewControllers. Also, you can create a Model class to represent data as well.

The Main Controller provides the other two controllers with this modal object

Puneet Sharma
  • 9,369
  • 1
  • 27
  • 33
0

In my opinion, for your scenario, you should keep your dataModel class separate and use Singleton pattern. Same dataModel object should be used for both ViewControllers.

san
  • 3,350
  • 1
  • 28
  • 40