views:

26

answers:

1

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,

  1. Dump plist into an array
  2. Use objectAtIndex to access the images (remember, arrays start at index 0)
iWasRobbed