and I synthesize it and use it in Mode1View.m, but in another class ChangeViews.m I would like to change the value of it to NO;
In ChangeViews.m I have:
You have to understand that what you are doing there is creating a new object of the ModelView type class and settings its value.
There are different ways to approach this but it depends on your code structure. Is ModelView a viewcontroller, what aboutChangeViews too? One way would be to make the ModalView a singleton, that way only one instance of the object will exist, and the code you used would work. The other, if your ModelView controller loads the ChangeViews controller, it could pass the pointer to the object to it, so ChangeViews could access the object that way.
You have to understand that what you are doing there is creating a new object of the ModelView type class and settings its value.
There are different ways to approach this but it depends on your code structure. Is ModelView a viewcontroller, what aboutChangeViews too? One way would be to make the ModalView a singleton, that way only one instance of the object will exist, and the code you used would work. The other, if your ModelView controller loads the ChangeViews controller, it could pass the pointer to the object to it, so ChangeViews could access the object that way.
Mode1View is a view, with a seperate view controller for it, and changeViews is a view controller. How would I make Mode1View a singleton?
But note that the class you do this for will only be able to have one object. Each time you create (alloc init) an object from that class, it will point to the same object. Used where appropriate it is a very useful design pattern.
The reason that isn't working is because you are creating another instance of the class. You need to access the existing instance. If your appDelegate owns the class, then you can use the appDelegate to get access it.
Code:
AppNameAppDelegate *appDelegate = (AppNameAppDelegate *)[[UIApplication sharedApplication] delegate];
// Use the app delegate to access theClass
AppNameAppDelegate *appVC = appDelegate.theClass;
// Set the variable named Variable
[theClass setVariable:FALSE];
But note that the class you do this for will only be able to have one object. Each time you create (alloc init) an object from that class, it will point to the same object. Used where appropriate it is a very useful design pattern.
Thanks a lot! Was able to get it to work, added you to list of awesome people, and now I know how to do it in the future