• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Referencing files in the app's bundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Referencing files in the app's bundle


  • Subject: Re: Referencing files in the app's bundle
  • From: Philip George <email@hidden>
  • Date: Sat, 27 Jul 2002 09:18:00 -0500

You can use NSBundle's mainBundle method to set the path at the top of
your bundle and then recursively search though the bundles folders for a
particular resource with pathForResource, like so:

NSString * pathToXML = [[NSBundle mainBundle]
pathForResource:@"nameOfFile" ofType:@"xml"];

I just looked at the NSBundle documentation, and you actually have
several choices. Another way that looks like it would do the same thing
would be:

NSString * pathToXML = [NSBundle pathForResource:@"nameOfFile"
ofType:@"xml" inDirectory:[NSBundle mainBundle]];

Pretty much the same thing I think.

- Philip



On Saturday, July 27, 2002, at 07:25 AM, David H wrote:

> *This message was transferred with a trial version of CommuniGate(tm)
> Pro*
> Hi all, I'm trying to reference a file contained in the app's bundle
> (an XML file to be loaded into a NSDictionary object). The file is
> located in "MyApp.app/Contents/Resources/dict.xml", and if I use that
> path as is in my code, the file is loaded successfully in Project
> Builder, but if I move the app out to the Applications or any other
> directory, the XML file fails to load. Is there some way to reference
> files inside the bundle, ie. "~/Contents/Resources/dict.xml" or
> equivalent?
>
> http://digital.yahoo.com.au - Yahoo! Digital How To
> - Get the best out of your PC!
> _______________________________________________
> cocoa-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Referencing files in the app's bundle
      • From: Douglas Davidson <email@hidden>
References: 
 >Referencing files in the app's bundle (From: David H <email@hidden>)

  • Prev by Date: Can anyone tell me why this AppleEvent code isn't working?
  • Next by Date: Using NSToolbar itemForItemIdentifier properly?
  • Previous by thread: Referencing files in the app's bundle
  • Next by thread: Re: Referencing files in the app's bundle
  • Index(es):
    • Date
    • Thread