0

I'm trying to load a value from my plist which is the base name of the animated image I want to create. Essentially, I want my plist to contain the name image-.jpg, and use the code to do the rest.

I've gotten the idea from here Display animated GIF in iOS

and now I'm just trying to mix a plist into play. So far I've gotten this:

imageName.image = [UIImage animatedImageNamed:[[myArray objectAtIndex:indexValue] valueForKey:@"imageName" duration:1.0f]];

The valueForKey is image-.jpg, so when iOS runs animatedImageNamed it would be image-1.jpg, image-2.jpg, etc.

My issue is that Xcode displays an error at animatedImageNamed, saying there's no known method for selector.

How can I fix this?

Community
  • 1
  • 1
DiscoveryOV
  • 1,045
  • 2
  • 9
  • 24
  • BTW - change `valueForKey:` to `objectForKey:` assuming you have an array of dictionary in your plist file. Better yet, use modern syntax: `myArray[indexValue][@"imageName"]`. – rmaddy Jul 07 '15 at 16:14

1 Answers1

2

I think the issue is with the placement of ']' :) May be the statement should look like

imageName.image = [UIImage animatedImageNamed:[[myArray objectAtIndex:indexValue] valueForKey:@"imageName"] duration:1.0f]
Subbu
  • 2,138
  • 14
  • 20
  • Yup, that was it. Dang. And for anyone that may be looking: using this method means your image extension doesn't matter (and you actually can't add the .jpg, .png, etc.) on your plist or image files. – DiscoveryOV Jul 07 '15 at 17:13