Home > DeveloperSection > Forums > How can I find images using iPhone app?
Tarun Kumar

Total Post:210

Points:1614
Posted on    September-10-2015 11:30 PM

 iPhone iPhone  Ios  Objective C 
Ratings:


 1 Reply(s)
 564  View(s)
Rate this:

My app crashes when I do the following in the applicationDidFinishLaunching event in the app delegate:

_textures[mytex] = [[Texture2D alloc] initWithImage:
                    [UIImage imageNamed:@"color.png"]];

However when I replace @"color.png" with

@"/Users/MyUserName/Desktop/MyProjectFolder/color.png"

everything works fine. I've experimented with the relative path stuff for the color.png resource... but none of it has worked. How can I fix this? I'd like to just say @"color.png" for all the image resources (esp. since I did this in another app... where I was working directly with sample code).

So what is that magical setting?

Thanks!


Glen Martin
Glen Martin

Total Post:27

Points:191
Posted on    September-11-2015 2:24 AM

+[UIImage imageNamed:] will look in your app bundle's resources to find the image.
If you add an image to Xcode it will be default be added to the resource copy phase of your project. If you want to make sure it is being copied into your app bundle look at the list on the left side of your Xcode editor, under targets you will see your app name there, under that you will see several build phases, so long as color.png appears in the "Copy Bundle Resources" phase you should be good to go.

Don't want to miss updates? Please click the below button!

Follow MindStick