我要将ios应用程序路径定义为常量,那么我应该如何以编程方式设置PATH常量。 以下是摘录:
NSString *dirPath = @"/var/mobile/Applications/7BCC7E9C-18DE-4AFD-A7BA-9E8070D39161/Documents/" ;
如何将此dirPath设置为以下
#define PATH L"/var/mobile/Applications/7BCC7E9C-18DE-4AFD-A7BA-9E8070D39161/Documents/"
或 设置为wchar_t:
wchar_t *path = dirPath;
答案 0 :(得分:0)
NSString *documentDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
甚至:
#define DOCUMENT_DIR [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
答案 1 :(得分:0)
// Returns the URL to the application's Documents directory.
- (NSURL *)applicationDocumentsDirectory
{
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}