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 ot开发者_StackOverflow中文版her functions?
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. ;)
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
精彩评论