首页 > 移动平台 > 详细

IOS获取资源路径

时间:2019-04-09 21:28:27      阅读:130      评论:0      收藏:0      [点我收藏+]

  1. 获取已经添加到xcode工程中的某一资源文件 file.txt 的路径

NSString *filePath_= [[NSBundle mainBundle] pathForResource:@"file" ofType:@"txt"];
std::string filePath =std::string([filePath_ UTF8String]);

 

2. 对当前xcode工程开通沙盒权限后,访问存储到手机上的某一资源文件夹sources/file.txt的路径

    NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
    NSString *fileDir = [docDir stringByAppendingPathComponent:@"sources"];
    NSString *filePath = [fileDir stringByAppendingPathComponent:@"file.txt"];

    std::string filePath_=std::string([filePath UTF8String]);

 

IOS获取资源路径

原文:https://www.cnblogs.com/riddick/p/10677806.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!