Mac 下命令行使用Cmake与PlistCpp开源库的使用
来源:互联网 发布:mac找不到拼音输入法 编辑:程序博客网 时间:2024/05/11 05:02
一. Mac 下安装Cmake,并在终端上使用Cmake,解决cmake命令command not found
1. cmake下载
去官网https://cmake.org/download/
选择对应的版本:
2. 在mac系统上直接安装,则有相应的UI界面的cmake可以使用
安装好gui界面后,进入目录/Applications/CMake.app/Contents/bin/cmake-gui
找到cmake图标,右键显示包内容
3. 将cmake添加到终端,使得在终端也可以使用cmake
在终端输入命令:
sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install
这样就可以在终端使用cmake,而不会提示command not found之类的错误了。
二. IOS中使用PlistCpp开源库
1. PlistCpp开源库的github地址:
https://github.com/animetrics/PlistCpp
由于需要依赖mac下的boost,具体配置boost的方法参考上一篇博文:http://blog.csdn.net/waterbinbin/article/details/62438417
2. 配置PlistCpp
新建一个ios项目,其实不需要按照github上的说明来操作,只要添加相应到文件到项目即可使用
3.具体使用方法参考源码plistTests.cpp文件或者博客http://blog.csdn.net/c_singleboy/article/details/38677459
简单的demo使用如下:
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. Plist::dictionary_type dict; NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"binaryExample1" ofType:@"plist"]; const char* path = [plistPath UTF8String]; Plist::readPlist(path, dict); for(Plist::dictionary_type::const_iterator it = dict.begin(); it != dict.end(); ++it) { cout<< "key: "<< it->first <<endl; } //读数组 const Plist::array_type& plistArray = boost::any_cast<const Plist::array_type&>(dict.find("testArray")->second); cout << boost::any_cast<const int64_t&>(plistArray[0]) << endl; cout << boost::any_cast<const string&>(plistArray[1]).c_str() << endl; //读字典 const Plist::dictionary_type& plistDic = boost::any_cast<const Plist::dictionary_type&>(dict.find("testDict")->second); Plist::dictionary_type::const_iterator it = plistDic.begin(); cout << "key:" << it->first << endl; cout << boost::any_cast<const string&>(it->second) << endl; //读一个变量 const Plist::Date& date = boost::any_cast<const Plist::Date&>(dict.find("testDate")->second); std::string strDate = date.timeAsXMLConvention(); cout << boost::any_cast<const string&>(strDate) << endl; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *path1 = paths[0]; NSString *filePath = [path1 stringByAppendingPathComponent:@"writeBinary.plist"]; const char* filePath1 = [filePath UTF8String]; //写数组1 Plist::dictionary_type dic; dic.insert(make_pair("testArray1", plistArray)); //Plist::writePlistBinary(filePath1, dic); //写数组2 vector<boost::any> array(2); array[0] = 50; array[1] = string("mystring ok in array"); cout << boost::any_cast<const int&>(array[0]) << endl; cout << boost::any_cast<const string&>(array[1]).c_str() << endl; dic["testArray2"] = array; Plist::writePlistBinary(filePath1, dic); Plist::dictionary_type dicR; Plist::readPlist(filePath1, dicR); //读数组 const Plist::array_type& plistArrayR = boost::any_cast<const Plist::array_type&>(dicR.find("testArray2")->second); cout << boost::any_cast<const int64_t&>(plistArrayR[0]) << endl; cout << boost::any_cast<const string&>(plistArrayR[1]).c_str() << endl;}
demo下载链接:
http://download.csdn.net/detail/waterbinbin/9804929
本博客参考文章:
http://blog.csdn.net/baiyu9821179/article/details/54632135
http://blog.csdn.net/yuanya/article/details/51098777
http://blog.csdn.net/c_singleboy/article/details/38677459
0 0
- Mac 下命令行使用Cmake与PlistCpp开源库的使用
- cmake在linux,windows,mac下的安装与使用
- cmake在linux,windows,mac下的安装与使用
- Mac环境下svn命令行的使用
- Mac环境下svn命令行的使用
- Mac环境下svn命令行的使用
- Mac环境下svn命令行的使用
- Mac环境下svn命令行的使用
- Mac 下使用EasyPR的方法,CMake,OpenCV
- windows下cmake的使用
- Windows下CMake的使用
- mac环境下cmake命令行编译总结
- CMake再Mac下设置命令行
- [CMake] CMake的使用
- mac 系统 命令行的使用
- CMake 的安装与使用
- CMake的介绍与使用
- MAC 下使用命令行编译代码
- python cv2 sift match
- 子字符串查找
- 使double保留两位小数
- HTML5中使用canvas绘制矩形
- webstorm相关设置
- Mac 下命令行使用Cmake与PlistCpp开源库的使用
- Jenkins邮箱发送配置
- 并发 并行 同步 异步 多线程的区别
- ORA-00257: archiver error. Connect internal only, until freed——解决
- Windows和linux的Composer安装
- java基础开发(七)
- BZOJ 3504: [Cqoi2014]危桥
- poj 2406 Power Strings KMP
- 交叉编译点亮小灯