Skip navigation.
 
mlRe: Launching Cocoa Application externally
FROM : Sherm Pendley
DATE : Thu May 15 18:56:09 2008

On Thu, May 15, 2008 at 12:42 PM, Yann Disser <<email_removed>> wrote:

> Thank you all for your help. I managed to fix the problem by going over
> your suggestions.
>
> 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.



You shouldn't rely on the current working directory. Just use the call to
-bundlePath (or one of NSBundles many other methods for finding paths to
different bundle internals) to create a fully-qualified path to the file you
want to open.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net

Related mailsAuthorDate
mlLaunching Cocoa Application externally Yann Disser May 14, 15:48
mlRe: Launching Cocoa Application externally Stéphane May 14, 15:55
mlRe: Launching Cocoa Application externally Jean-Daniel Dupas May 14, 16:20
mlRe: Launching Cocoa Application externally Jens Alfke May 14, 16:47
mlRe: Launching Cocoa Application externally Yann Disser May 14, 17:13
mlRe: Launching Cocoa Application externally Andy Lee May 14, 17:30
mlRe: Launching Cocoa Application externally Stuart Malin May 14, 19:56
mlRe: Launching Cocoa Application externally Jean-Daniel Dupas May 14, 20:55
mlRe: Launching Cocoa Application externally Yann Disser May 15, 18:42
mlRe: Launching Cocoa Application externally Jean-Daniel Dupas May 15, 18:48
mlRe: Launching Cocoa Application externally Sherm Pendley May 15, 18:56
mlRe: Launching Cocoa Application externally Jens Alfke May 15, 20:45
mlRe: Launching Cocoa Application externally Douglas Davidson May 15, 20:49