iOS Storyboard clobbering variables when pushing scenes? Why? How should it be done? -


i have following storyboard configuration in ios project.

storyboard1->navcontroller-scenea->stoyboard2/initialview

storyboard2->sceneb->scenec

-> "show" segue scene loads storyboard , pushes onto navigation controller.

  • scene has controller instances class x.
  • scene b uses default uiviewcontrooler class.
  • scenec has controller instances class y.

the implementations both classes follows

//classx.h// @interface classx : uitableviewcontroller  //classx.m// @implementation classx nsarray* model;  //.. @end   //classy.h// @interface classy : uitableviewcontroller  //classy.m// @implementation classy nsarray* model;  //.. @end 

the problem when try load scene c, tries use field called "model" in implementation– gets field of model scene reason. why , how should correct it?

you should make model property of classes rather declaring them do. creating global variables. or declare them inside {} after @implementation make sure variables part of class.

so either:

@implementation{   nsarray *model } ... @end 

or better use private properties , use self.model in code.:

so in classy.m try:

@interface classy ()    @property nsarray *model; @end  @implementation classy ... @end 

do same classx.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -