views:

15

answers:

2

In viewDidLoad, an object is created. In some other function, I want to do something with the object, but outside of viewDidLoad, the object is not recognized. How can I access the object from other functions?

+2  A: 

you have to declare that object in your view controllers header (not in viewDidLoad). you can initialize the object in viewDidLoad. Now it will be visible in every method (not function) within that class. ;)

nacho4d
A: 

If you want the object to be accessable by all other variables in the same level, you'll have to declare it in the same level as viewDidLoad and the other function.

//start of program
            //declare the object
            //declare viewDidLoad
              //--
            //declare other function
              //--
//end of program
Greg Treleaven