【发布时间】:2011-04-17 08:11:49
【问题描述】:
我首先将 3 值存储到一对映射中,如下所示:
void AddMenuAtlasTexture( int tag, const char* filename, const char* textureName )
{
map<const char*, const char*> _item;
_item.insert(pair<const char*, const char*>(filename, textureName));
m_texturesToLoad.insert(pair<int, map<const char*, const char*> >(tag, _item));
};
然后我将值传递给另一个函数,如下所示:
map<const char*, const char*>::iterator _content;
int _tag = (*m_texturesToLoadIterator).first;
_content = (*m_texturesToLoadIterator).second.begin();
AtlasManagerSingleton->AddAtlas((*_content).first, (*_content).second, _tag);
“textureName”是这样的绝对路径:“/Users/eddy/Library/Application Support/iPhone Simulator/User/Applications/5FDE0091-2E93-42FE-BB62-05A16429551D/Ranch.app/../文件/shop_tex.png"
我的问题是第一个函数可以正确获取“textureName”,但第二个函数“AddAtlas”无法获取路径,“(*_content).second”为NULL。
“AddAtlas”原型是:
void AtlasManager :: AddAtlas( const char *a_configFile, const char *a_spriteName, int a_nKey )
我在 iPhone 开发中使用 XCode 进行开发。
【问题讨论】:
-
显示你用来调用
AddMenuAtlasTexture的所有代码。 -
提示:您可以使用 -> 运算符代替 (*pointer).stuff。你可以做指针->东西。
-
尝试使用 m_texturesToLoadIterator->second 代替 (*m_texturesToLoadIterator).second 我认为这可能是运算符重载问题
-
谢谢你的回答,但是我改成这个“_content = m_texturesToLoadIterator->second.begin();”后,还是取不到字符串。
-
为什么你不使用 std::string?
标签: iphone char constants objective-c++