• 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: Opening file with C++ iostream from application bundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Opening file with C++ iostream from application bundle


  • Subject: Re: Opening file with C++ iostream from application bundle
  • From: Alexander Spohr <email@hidden>
  • Date: Mon, 20 Apr 2009 14:29:58 +0200


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 (email@hidden)

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:
This email sent to email@hidden


References: 
 >Opening file with C++ iostream from application bundle (From: Carlos Eduardo Mello <email@hidden>)

  • Prev by Date: Opening file with C++ iostream from application bundle
  • Next by Date: Re: Is there a way where we can avoid the machine from going to sleep...?
  • Previous by thread: Opening file with C++ iostream from application bundle
  • Next by thread: Re: Opening file with C++ iostream from application bundle
  • Index(es):
    • Date
    • Thread