How can I use the value of a variable from one class in another in Objective-C?
I am fairly new to Objective-C and have been doing some iPhone programming.
Is it possible to look up the va开发者_JAVA百科lue of a variable in a different class?
Basically what I am doing is running a function that exists in my application delegate from a view controller, but the application delegate needs to use a variable stored in the view controller from which the application delegate function was called. Does it make sense?
You can always pass the variable into the function which needs it. Or you can make a getter for it
Fixed the problem by simply passing the variable to the app delegate and doing it that way.
It sounds to me that you need to expose that variable as a property.
You can create a singleton and store your data and have it available all over the place.
精彩评论