I have a little problem, when I have to access to one class I create a new instance
Class *class = [[Class alloc] init];
the problem is that I don’t want to create a new instance but use the current instance, I want only to communicate between two class…how can I pass a value without create a new instance?
You can use a Singleton class to create a shared object that can be accessed for the lifetime of the app, here’s a simple (though not 100% foolproof) way to create one:
More here
If you just want to perform specific operations, or get information from the class, you can use a class method by using “+” instead of “-” in the method name like so:
Then you can simply call [Class doSomething] to perform operations without having to create a new instance.