开发者

Cocoa/Finder: weird path

开发者 https://www.devze.com 2023-03-10 11:29 出处:网络
im asking the finder for the current finder window location/path/whatever with NSString *path = [[finder insertionLocation] get];

im asking the finder for the current finder window location/path/whatever with

NSString *path = [[finder insertionLocation] get];

which results in a path like that:

2011-06-03 18:38:55.132 CutIt[1980:903] <FinderFolder @0x1561d960: FinderFolder "eike" of FinderFolder "Users" of startupDisk of application "Finder" (185)>

is there a 开发者_JAVA技巧common way to convert that into a usable path, like /users/eike, or do i have to patch something together myself?


A little bit nested, but you can divide it as you like:

NSString *path = [[NSURL URLWithString:[[[finder insertionLocation] get] URL]] path];


In case anyone is interested, here's a way to get the path without the casting warning:

NSURL *insertLocation = [[[finder insertionLocation] get] URL];
NSString *path = [[NSURL URLWithString:[NSString stringWithFormat:@"%@",insertLocation]] path];
0

精彩评论

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

关注公众号