Where do you put global application data in an iPhone app?

后端 未结 2 514
北荒
北荒 2021-02-09 18:54

I have an app that allows the user to view, manipulate and manage a collection of Schedule objects. Different parts of the app need access to this data. I\'ve experimented with

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-09 19:45

    Many people store everything in the AppDelegate and access the data through [[UIApplication sharedApplication] delegate].

    If the data are supposed to be persisted, you could also use the NSUserDefaults singleton.

    If the data are big, maybe you need SQLite.

    This is for "global" data as you asked.

    If your view controllers are organized in tree, a better way would be passing the required data from parent UIViewController to child UIViewController.

提交回复
热议问题