Re: XML plist to NSArray
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.