• 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: XML plist to NSArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML plist to NSArray


  • Subject: Re: XML plist to NSArray
  • From: Brian Webster <email@hidden>
  • Date: Sun, 8 Jun 2003 12:59:29 -0500

On Saturday, June 7, 2003, at 04:02 PM, email@hidden wrote:

I don't where Apple explains that you need "Contents/Resources" in your
path. I discovered it by logging directory lists until I found it.

You can retrieve this path from an NSBundle using the resourcePath method. But, the preferred way to retrieve the path of a resource inside a bundle is to use the pathForResource:ofType: method. The main reasons for this are a) you aren't hard coding the resources path, so if for some reason the organization of bundles should change in the future, your code won't break, and b) this method will correctly search your localized .lproj directories and return the path of the resource that matches the user's preferred language. So, the code becomes:

- (NSMutableDictionary*)plistFromBundle:(NSString*)nameWithoutSuffix
{
NSString* plistPath = [mBundle pathForResource:nameWithoutSuffix ofType:@"plist"];

NSMutableDictionary* plistDictionary = [[NSMutableDictionary alloc]
initWithContentsOfFile:plistPath];

//This needs to be autoreleased when returned
return [plistDictionary autorelease];
}

--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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:
    • Disable spell checking menu in NSTextField
      • From: Arthur Clemens <email@hidden>
  • Prev by Date: Can't find plist
  • Next by Date: Re: NSDistributedNotificationCenter question
  • Previous by thread: Re: XML plist to NSArray
  • Next by thread: Disable spell checking menu in NSTextField
  • Index(es):
    • Date
    • Thread