FROM : Jens Alfke
DATE : Thu May 15 20:45:36 2008
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
DATE : Thu May 15 20:45:36 2008
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
| Related mails | Author | Date |
|---|---|---|
| Yann Disser | May 14, 15:48 | |
| Stéphane | May 14, 15:55 | |
| Jean-Daniel Dupas | May 14, 16:20 | |
| Jens Alfke | May 14, 16:47 | |
| Yann Disser | May 14, 17:13 | |
| Andy Lee | May 14, 17:30 | |
| Stuart Malin | May 14, 19:56 | |
| Jean-Daniel Dupas | May 14, 20:55 | |
| Yann Disser | May 15, 18:42 | |
| Jean-Daniel Dupas | May 15, 18:48 | |
| Sherm Pendley | May 15, 18:56 | |
| Jens Alfke | May 15, 20:45 | |
| Douglas Davidson | May 15, 20:49 |






Cocoa mail archive

