I have a simple iOS app in which one class called Dictionary (.m and .h) has several functions for building an NSArray of NSDictionary objects and then functions to manipulate that data structure. I have a UITableViewController class that has the table view delegate methods, but I can’t figure out how to create an instance of the Dictionary class in that UIViewController in order to be able to have all of the delegate methods talk to that instance of the class (e.g. when i call Dictionary *dictionary = [[Dictionary alloc] init] in the viewDidLoad method, I can’t access any of that instance in the cellForRowAtIndexPath delegate method. New to iOS programming and feeling very frustrated with it! Any help would be greatly appreciated.
I have a simple iOS app in which one class called Dictionary (.m and
Share
Sounds like you need to declare dictionary as a member variable of your class.
There are several ways to do this. The quickest is to put the following above the @implementation call in your .m file of your table view controller.
Make sure to replace nameOftableViewControllerClass with the actual name of your view controller class.
Then, in view did load. you can call the following
Then in the cellForRowAtIndexPath you can call any functions on the dictionary object.
Don’t forget to put a release call in the dealloc method of your table view controller.
hope this helps, hit my up if you have any more problems