iPhone Coding: Use NSBundle and avoid hard-coded paths
An NSBundle object locates your app in the local file system so you can access resources and use them in your programs.
[NSBundle mainBundle] returns the object for your app. When you use the pathForResource: ofType: inDirectory: method, you can easily find the path to those resources. For example, to find the Default.png file in the top level of an iPhone or iPod touch application, use:
[[NSBundle mainBundle] pathForResource:@"Default" ofType:@"png" inDirectory:@""]]. Couldn't be simpler.
Skip the type argument (use @"") for resources without extensions.
Subscribe to Newsletter
Software Updatesmore updates
- IFTTT adds a location channel to its iOS App
- Plants vs. Zombies 2 gets upgraded map, more 'cool' stuff
- Remote Desktop update brings OS X Mavericks support and improved multi-display support
- Valve revamps Steam Mobile for iOS
- Google Drive iOS app finally lets you sort items and find and replace in documents
- Viber announces Viber Out calls for iOS, goes head to head with Skype