Newbie here,
I have a single component picker set up from a plist, with each item being an array, with multiple strings in each array that the app uses.
Currently the plist structure is like this:
NSDictionary -> NSArray -> NSString
| |
Items in Picker Data for each Item
But now, I want:
NSDictionary -> NSDictionary -> NSArray -> NSString
| | |
DIfferent Picker Data Sets Items in Picker Data for each Item
So now there would be multiple sets of picker components that I would show using a segmented control etc…
I’m not even sure if this is possible, and I was only hoping it would save me from making many different separate picker controllers.
What has me stumped is just getting everything ingested properly
This is what I have now, it builds successfully but crashes (debug info below):
NSBundle *bundle = [NSBundle mainBundle];
NSString *plistPath = [bundle pathForResource:@"CamerasDatabase" ofType:@"plist"];
NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:plistPath];
self.allCameras = dictionary;
[dictionary release];
NSArray *cameraTypes = [self.allCameras allKeys];
self.CamTypes = cameraTypes;
NSArray *items = [self.CamTypes objectAtIndex:0];
self.Cameras = items;
NSString *selectedCamera = [self.Cameras objectAtIndex:0];
NSArray *array = [CamsList objectForKey:selectedCam];
self.cameraData = array;
I’ve tried many different combinations of dictionaries, arrays, and strings so I’m sure the above code is messed up.
It crashes at:
NSString *selectedCamera = [self.Cameras objectAtIndex:0];
with “-[NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x4e127f0”
It is obvious, you are having NSString objects (keys) in self.CamTypes. Not NSArray.
so these lines are invalid
for fixing this write code some thing like this
so in above code self.allCameras is the dictionary which having arrays corresponding different key (cameraTypes which are in self.CamTypes).