On 15 May '08, at 9:42 AM, Yann Disser wrote:

The problem was that I access a file (without proper error-handling; I will add that now :-)). The default working directory is the main- bundle path when run from within XCode and it is "/" when run from Finder.

I repaired this by adding
[[NSFileManager defaultManager] changeCurrentDirectoryPath:
[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent]];
to my awakeFromNib. I hope this works as I intend.


That will work, although if any other -awakeFromNib method (of an object in that nib) wants to use a relative path, you have a race condition, because the order in which -awakeFromNib methods are called is, basically, random.

But it's better to just avoid using relative paths, if possible. If you're accessing a file inside your bundle, you should use the NSBundle resource APIs to get its location.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to