开发者

Next Item in Plist Button

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 ce开发者_JS百科ll 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


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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜