Reputation: 241
The image file afghanistan.png
is located in a Group called Flags within the Resources Group of an iOS project. I want to access this image in a UITableViewCell. When I call it, it returns (null)
. Is
<string>/Flags/afghanistan.png</string>
the correct path to the file?
<plist version="1.0">
<array>
<dict>
<key>name</key>
<string>Afghanistan</string>
<key>government</key>
<string>Islamic Republic</string>
<key>population</key>
<integer>0</integer>
<key>image</key>
<string>/Flags/afghanistan.png</string>
</dict>
Upvotes: 2
Views: 765
Reputation: 11465
Bear in mind that the Grouping of files within an Xcode project is only a virtual "directory", not a real one.
With that in mind, you will probably find that the image is not in a /Flags directory at all, but rather in the root directory (or another completely different one). Try changing it just to
<key>image</key>
<string>afghanistan.png</string>
Also, remember that iPhone is case sensitive and Mac isn't! This can lead to things working in the simulator but not on the phone...
Upvotes: 1
Reputation: 4989
If your trying to access this file from your project code, the correct path would be something like:
NSString *filePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Flags/afghanistan.png"];
This of course assumes that the file is actually in the right place. In the .plist file, you'd probably be better off using the full path, something like: /Users/username/MyApp/Resources/Flags/afghanistan.png or whatever your path might be.
Upvotes: 2