开发者

How to get the current working directory's absolute path in Objective-C?

How do 开发者_开发知识库I get the current working directory's absolute path on the iPhone using Objective-C?


I'm afraid that you can't get the absolute path on device, at least with official SDK. Please make me correct if I'm wrong.


Not sure whether this works on iPhone, but it should.

char *buf = getwd();
NSString *cwd = [NSString stringWithCString:buf encoding:NSUnicodeStringEncoding];
free(buf);

You might need to fiddle with the right encoding...

EDIT: aaaehm, you might also just want to try NSFileManager's currentDirectoryPath method...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜