How do I pass variables between view controllers?

前端 未结 6 1403
礼貌的吻别
礼貌的吻别 2020-12-06 20:21

i\'m having a hard time with Xcode; for some reason, it just won\'t let me pass a variable from one view controller class to another. It should work, i was basically just co

6条回答
  •  旧巷少年郎
    2020-12-06 21:19

    A more competent way of doing this is to separate the data from both the viewcontrollers into a model. You will have a separate class(NSObject) called ResultadoModel.h/m. This will be a singleton, so both classes can access the same instance.

    You would access the array by doing something like this(in both vcs):

    [[[ResultadoModel sharedInstance] array_resultados] propertyOrMethod];
    

    You can search how to create a singleton, it's very simple and very powerful.

提交回复
热议问题