1

I got a UINavigationController holding 3 Catalog View controllers

  1. Categories
  2. Items
  3. Selected Item

Looking for a design pattern how to manage the flow.

Scenarios

  1. User pick category and then pick an item
  2. New item from different category was selected from the last vc, so the vc update it's view with the relevant data but he also need to update the items of the category in the second VC and need to update the Categories VC with the selected Category of that item..

The flow is bidirectional and all data is coming from the server which make everything be in an unknown state.

Looking for a way to solve it nicely

Antony
  • 14,900
  • 10
  • 46
  • 74
ibm123
  • 1,214
  • 2
  • 15
  • 39

1 Answers1

0

Based on your description, observer pattern should be a good choice.

The observer pattern is like this: an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used to implement distributed event handling systems.

For you case, if a new item is selected in the view controller, this view controller should fire an item selected event, and the other view controller who wants to be notified on this event, will register a event handler on this event, so when event is first, other view controller will get notified.

Please refer this: What's the nicest way to do observer/observable in objective-c (iphone version)

Community
  • 1
  • 1
Matt
  • 6,010
  • 25
  • 36