Load custom class properly
- by LinusAn
I have a custom class which I want to "load" inside the firstViewController and then access it from other classes by segues. My Problem is, I can't even access and change the instance variable inside the firstViewController. Somehow I'm "loading" it wrong. Here is the code I used until now:
inside viewController.h
@property (strong, nonatomic) myClass *newClass;
inside viewController.m
@synthesize newClass;
I then try to access it by:
self.newClass.string = @"myString";
if(newClass.string == @"myString"){
NSLog(@"didn't work");
}
Well, I get "didn't work". Why is that?
When I write
myClass *newClass = [myClass new];
It does work. But the class and its properties gets overwritten every time the ViewController loads again.
What would you recommend? Thank you very much.