Reputation: 6614
I have a plist (dictionary type) populating text views and labels on one view. I would like to have an info UIButton on this first view that links to a separate view and displays some data from the same plist.
it has to be data from the same record in the plist though.
I have everything working, but I'm stuck at being able to pass that data to the second view.
any hints/help is greatly appreciated,
thanks,
Upvotes: 0
Views: 191
Reputation: 421
You could just Create a NSDictionary in the .h file of the second view and then when you are moving to the next view set the dict you want to pass as that dictionary.
SecondView* view = [SecondView .......
view.passedDictionary = currentDict;
//then push the new view onto the screen
In the .h file of the second view
NSDictionary* passedDictionary;
@property(nonatomic, retain) NSdictionary* passedDictionary;
Upvotes: 0
Reputation: 3051
Or you could make a property in the info view.
@property(nonatomic, retain)NSDictionary *myDic;
And when you create the Info view, pass your dictionary with the data to the second view, which then displays the data. ;-)
Upvotes: 1
Reputation: 1984
You could open the same plist in the next view and read the data in the same way:
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"Info.plist"];
NSDictionary *plistData = [[NSDictionary dictionaryWithContentsOfFile:finalPath] retain];
You could make a Singleton
accessor class for your dictionary and have both views request an instance of it to gain access to the same data.
Or if you create your views programmatically, you could just create a setter in your new view controller and pass a reference of your dictionary from the original view controller.
Upvotes: 0