bundelPath没有应用程序名称

时间:2013-01-08 14:42:55

标签: xcode cocoa-bindings

我需要获取应用程序的路径(bundlePath或bundleURL)而不使用应用程序名称

NSUrl *strUrl = [[NSBundle mainBundle]bundleURL];

NSString *str = [[NSBundel mainBundel]bundlePath];

我该怎么做

1 个答案:

答案 0 :(得分:3)

NSURLNSString都有删除最后一个路径组件的方法,因此这应该可以提供您想要的内容:

NSURL *strUrl = [[[NSBundle mainBundle] bundleURL] URLByDeletingLastPathComponent];

NSString *str = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
相关问题