tags:

views:

537

answers:

3

I have placed my images in XCode Groups&Files, in this location:

Ressources/img/

But now I look at the UICatalog XCode project from apple, and they put all images here:

images/

It seems like Interface Builder has no problem finding them, but as soon as I try that programmatically, all attempts fail.

+1  A: 

IB is always told where project images are, so it doesn't matter where you have them - just they are included in the project.

Images you create later have to be stored in the writable area the app has access to, and I don't think you can load them with UIImageNamed - you have to create a file URL for them and use the image from data methods.

Kendall Helmstetter Gelner
+1  A: 

You'll need to use pathForResource.

see: http://stackoverflow.com/questions/318341/how-to-fopen-on-the-iphone

Nick
oh but the UIImage imageNamed thing worked in the simulator?
Thanks
I think imageNamed looks in the bundle for you. I'm not sure though.
Nick
A: 

In Xcode, groups are just for organization, and all of the data files that you add to the project will be placed in the root of your application bundle, regardless of their group (assuming that the group isn't a folder, etc.). If you use a folder instead of a group, then the directory structure is preserved. I think UIImage imageNamed: always looks in the root.

dendryte