Typically, I would call another class method like this:
MyClass *class = [[MyClass alloc] init];
[class myMethod];
But the problem is that, it will call the ViewDidLoad. That is a problem for me.
Is there any way to access a property in another method or call a class in another method without calling the ViewDidLoad?
Thanks!
Edit1: So are you are saying that if I do this it will not call my VDL?:
MyClassB *classB = [[[MyClassB alloc] init] autorelease];
[classB.pauseButton setHidden:NO];
Also how about when I call a method will that trigger the ViewDidLoad?
Sure; refactor
myMethodto not callviewDidLoad.That is, if you call method
aand methodacallsb, but you don’t want to callb, then you need to modify the implementation ofato sometimes not callb. Either by modifyingaor creating a new methodcon the class containingathat doesn’t callb.If the problem is that you are calling a method in the system frameworks and it is calling
viewDidLoadwhen you don’t want, then the answer is that you really can’t do what you think you want to do. But that is just a symptom; the real answer is that your app’s architecture needs to be revisited to better fit with the system’s frameworks.That is creating a new instance of
MyClassB. If there is already an instance being displayed on screen, then you most likely do not need a new instance and, yes, that is the reason whyviewDidLoadis being called.Either create an instance variable that can point to the already existing instance of
classBor otherwise have a means of grabbing that instance; hang it off the app delegate or something.Overall, it sounds like you are confused about what it means to instantiate an object vs. simply referring to one and how all that fits into the UIKit model of app creation. It is a bit tricky until you get the hang of it. Study some of the many examples that show how to use view controllers as they will likely have solved a similar problem.