我使用 std::string path = cocos2d::CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(“data.json”); FILE *file1 = fopen( path.c_str(), “r” ); if ( file1 ) { CCLOG(“read file1 success”); }
ifstream file2(path.c_str()); if (file2) { CCLOG(“read file2 success”); }这样的代码想把data.json里的json格式内容读到程序里,但是失败了。。。。。。。加载不到内容,file1,file2都是NULL,但是,如果把data.json改为card.png的话file1,file2就不为空,要怎样才能加载到我自定义的这个data.json文件里的内容呢?这个data.json文件是放在Xcode项目里的Resources里的
本人刚自己解决了,可能是XCODE的问题,之前做是在XCODE里new一个GEOJSON文件,然后我把后缀改为.json,现在我在终端中touch 一个data.json文件,然后引到项目中就行了。。。。奇怪的问题。。。。。