How do I share an object between UIViewControllers on iPhone?

前端 未结 5 726
清酒与你
清酒与你 2020-11-28 22:48

My application is a tab bar application, with a separate view controller for each tab.

I have an object in my first view controller (A) which contains all my stored

5条回答
  •  离开以前
    2020-11-28 23:06

    Both view controllers should reference a third object (C) as their dataSource; this object (C) containing all the stored application data.

    C would be, in this case, the M in the MVC.

    Add to each of your ViewControllers the following declarations:

    // SomeViewController.h
    // Before @interface
    
    @class MyDataSource;
    
    // In the interface
    
    IBOutlet MyDataSource *datasource;
    @property(retain) IBOutlet MyDataSource *datasource;
    

提交回复
热议问题