Am 19.04.2009 um 03:50 schrieb Carlos Eduardo Mello:

1. I know this is not the recommended way to open a file in a Cocoa App, but this is just a quick utility

Your code is shorter than 2 lines Objective-C?

for use in class, so I don't wan't to change my file loading code and deal with File dialogs, bundle loading or preferences.

No dealings necessary.

This is not really a preferences file either. It contains some data which is vital to the application but will not be modified by the user.

2. Where should I place the file?

Inside resources. XCode will copy it to the right location.

3. How do I direct my executable to it so that I can load it with my stream reading code?

NSString *aPath = [[NSBundle mainBundle] pathForResource:@"Filename" ofType:@"extension"];


4. Can it be done with a path in info.plist or somethinglike that?

No. But you can load it with one of these lines, depending on the content:

NSData *someDataBlob = [NSData dataWithContentsOfFile:aPath
NSDictionary *aDictionary = [NSDictionary dictionaryWithContentsOfFile:aPath];
NSArray *anArray = [NSArray arrayWithContentsOfFile:aPath];


        atze

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to