QT for IOS 点滴

3 篇文章 0 订阅
2 篇文章 0 订阅

最近用QT做了android的相关开发,虽然在界面端对手机、平板的适应性不高,但做项目的效率还是挺高,在IOS方面也尝试了下,有点盲人摸象的感觉,但是QT对IOS、MAC的支持还是挺好的,QT下的C++代码+OC的语言,实现一些功能还是不错的,下面把获取 IOS下的存取目录的代码贡献出来

// 获取沙盒主目录路径

    NSString *homeDir = NSHomeDirectory();
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSError *error;
    //复制本地数据库文件到安装目录
    NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
    NSString *documentDirectory = [paths objectAtIndex:0];
    //APP安装目录中的document目录路径
    NSString *dbDir = [documentDirectory stringByAppendingPathComponent:@"/XX"];
    NSString *dbPath = [documentDirectory stringByAppendingPathComponent:@"/XX/XX.sqlite"];
    if([fileManager fileExistsAtPath:dbPath]==NO) {
        //项目中的数据库文件路径
        NSString *soudbPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"/XX/XX.sqlite"];
//        NSString *soudbPath = [homeDir stringByAppendingPathComponent:@"/XX.app/XX/XX.sqlite"];
        BOOL isDir = NO;
        BOOL existed = [fileManager fileExistsAtPath:documentDirectory isDirectory:&isDir];
        if(!(isDir == YES && existed == YES))
        {
            [fileManager createDirectoryAtPath:documentDirectory withIntermediateDirectories:YES attributes:nil error:&error];
            NSLog(@"123");
        }
        NSLog(@"456");
        existed = [fileManager fileExistsAtPath:dbDir isDirectory:&isDir];
        if(!(isDir == YES && existed == YES))
        {
            [fileManager createDirectoryAtPath:dbDir withIntermediateDirectories:YES attributes:nil error:&error];
            NSLog(@"789");
        }
        existed = [fileManager fileExistsAtPath:dbDir isDirectory:&isDir];
        if(!(isDir == YES && existed == YES))
        {
            [fileManager createDirectoryAtPath:dbDir withIntermediateDirectories:YES attributes:nil error:&error];
            NSLog(@"78910");
        }
        BOOL cp = [fileManager copyItemAtPath:soudbPath toPath:dbPath error:&error];
        NSLog(@"cp = %d",cp);
//        if (error != nil)
//        {
//            NSLog(@"[Database:Error] %@", error);
//        }
//        cp = [fileManager isReadableFileAtPath:dbPath];
//        NSLog(@"isReadableFileAtPath = %d",cp);
        NSLog(soudbPath);
    }
    else
    {
        NSLog(@"wucuowu");
    }

void XXXXXX::copy()

{
    void *copyfxxx = [[IOS_CPY alloc] init];
    [XXXX copyfxfx];
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

taanniu1

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值