0

我向取景器询问当前的取景器窗口位置/路径/无论如何

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

这导致了这样的路径:

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

有没有一种通用的方法可以将其转换为可用的路径,例如/users/eike,还是我必须自己修补一些东西?

4

2 回答 2

3

有点嵌套,但你可以随意划分:

NSString *path = [[NSURL URLWithString:[[[finder insertionLocation] get] URL]] path];
于 2011-06-03T16:48:37.393 回答
1

如果有人感兴趣,这是一种在没有投射警告的情况下获取路径的方法:

NSURL *insertLocation = [[[finder insertionLocation] get] URL];
NSString *path = [[NSURL URLWithString:[NSString stringWithFormat:@"%@",insertLocation]] path];
于 2012-09-01T18:00:28.513 回答