2013年4月18日木曜日

ApplicationSupportDirectoryのパスを得る

ApplicationSupportDirectoryのパスを得る
アプリ内でファイルを保存する場所として使う。


//Get Directory path
NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier];
NSFileManager *fm = [NSFileManager defaultManager];
dirPath = nil;

NSArray *appSupportDir = [fm URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask];

if ([appSupportDir count ] >0)
{
    dirPath= [[appSupportDir objectAtIndex:0]URLByAppendingPathComponent:bundleID];
    NSError *theErr = nil;
    if (![fm createDirectoryAtURL:dirPath withIntermediateDirectories:YES attributes:nil error:&theErr])
    {
        dirPath = nil;
    }
}

0 件のコメント:

コメントを投稿