What is a proper paradigm for having a mutable global value in objective-C -
so, let's displaying integer myint
value in oneviewcontroller
. then, while different view showing, anotherviewcontroller
, need increment or decrement myint
.
so scope needs global or @ least able accessed other viewcontrollers , needs mutable.
i know properties 1 way haven't been able them work. have been importing header file of oneviewcontroller
anotherviewcontroller
wasn't missing.
i've gone through several introductory books multi-view controller variable work wasn't explicitly covered in of them. i'm beginner please excuse conceptual misunderstandings.
doesn't have view controllers -- sort of custom classes.
in firstclass.h:
@property(whatever) int someintinfirstclass; -(void) somemethodinfirstclass;
secondclass.h
@property(whatever) firstclass* myparent;
firstclass.m
secondclass* second = [[secondclass alloc] init]; second.myparent = self; [second startsomething];
secondclass.m:
[self.myparent somemethodinfirstclass]; int x = self.myparent.someintinfirstclass; self.myparent.someintinfirstclass = x + 1;
Comments
Post a Comment