Hey guys, i have a simple app just a load of images in one image view. Each is just included in a plist file and called when a cell is selected in popover window. All i want is a button with an action to get next item in plist and display in the image window. this sounds easy but i cant figure out the code to grab next item in plist? can anyone help cheers
A:
I'm not sure what the structure of your property list is, but I'm just going to guess that it's just a property list with one string containing the image name per row. The easiest way to manage this is to just dump the plist file into an array like this:
// Load the data
NSString *pathToFile = [[NSBundle mainBundle] pathForResource:someArrayNameString ofType:@"plist"];
self.someArrayYouCreated = [NSArray arrayWithContentsOfFile:pathToFile];
then you can access the data in the array like this:
// load it into some string you created
nextImageNameString = [someArrayYouCreated objectAtIndex:nextImageNumberHere];
and then you can just use that string name as the next image to load. So basically,
- Dump plist into an array
- Use
objectAtIndex
to access the images (remember, arrays start at index 0)
iWasRobbed
2010-07-26 20:50:27