NSMutableDictionary-在将键值对设置为字典时出错

问题描述

|| 我收到以下代码的错误。
@interface event : NSObject
{
NSMutableDictionary  m_cAppIdMap;  //error:statically allocated instance of Objective C
}
@end
我通过事件实现中的create函数将对象设置为字典。
[m_cAppIdMap setObject:pEvent forKey:[NSNumber numberWithUnsignedInt:wTimerId]]; //Error:Cannot convert to a pointer type
这是我在字典上设置结构对象的方式。 pEvent是包含5个字段的结构,而wTimerId是无符号的短整数(键)。     

解决方法

您的ivar应该是一个指针。
NSMutableDictionary*  m_cAppIdMap;
    

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...