1
所以我有一个平台独立的API来加载一个文件,它将一个char *作为一个值。我在使用字符串文字的GetResource函数中编写了一些测试代码,它工作正常。但是,当我转换为使用char *并转换回NSString文件无法找到。将NSString转换为char时出现无法找到文件*
工作代码:
bool GetResource(const char* filePath, uint8*& allocatedBuffer, uint32& size) {
bool success = false;
NSString* path = [[NSBundle mainBundle] pathForResource: "models/testModel" ofType: @"obj"];
不工作代码:
NSString* nsModelString = @"models/testModel";
gDatastore->GetResource([nsModelString UTF8String], buffer, size);
....
bool GetResource(const char* filePath, uint8*& allocatedBuffer, uint32& size) {
bool success = false;
NSString* nsFilePath = [NSString stringWithFormat:@"%c" , filePath];
NSString* path = [[NSBundle mainBundle] pathForResource: nsFilePath ofType: @"obj"];
谁能告诉我什么,我用错了吗?有没有一种简单的方法来查看NSString并查看内容?