From my Mac OS app I was trying to get applications current directory using following code for generating a log file in the app bundle path.
NSString *path = [[[NSFileManager defaultManager] currentDirectoryPath] stringByAppendingPathComponent:@"TSPlogfile.txt"];
It worked fine when I run the application from Xcode but found [[NSFileManager defaultManager] currentDirectoryPath]
returns just /
while running the applicationxxx.app
from finder.
Later I solved this by using [[[NSBundle mainBundle].bundlePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"TSPlogfile.txt"];
This works fine in both case( running app from Xcode and from finder )
Can you explain why the [[NSFileManager defaultManager] currentDirectoryPath]
fails while running app from finder?