Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 不兼容的操作数类型(';NSUTEGER';(又名';无符号长';)和';id可为空';)_Ios_Objective C_Nsdictionary - Fatal编程技术网

Ios 不兼容的操作数类型(';NSUTEGER';(又名';无符号长';)和';id可为空';)

Ios 不兼容的操作数类型(';NSUTEGER';(又名';无符号长';)和';id可为空';),ios,objective-c,nsdictionary,Ios,Objective C,Nsdictionary,我有一个与将值赋给整数有关的问题: self.selectedGroup = GroupType //It is 3 from enum self.menuItemsPostion = @{[NSNumber numberWithInteger:GroupType]: @0, [NSNumber numberWithInteger:GroupTime]: @1}; NSUInteger itemToSelect = [self isCapturedEntriesContainClienst]

我有一个与将值赋给整数有关的问题:

self.selectedGroup = GroupType //It is 3 from enum

self.menuItemsPostion = @{[NSNumber numberWithInteger:GroupType]: @0, [NSNumber numberWithInteger:GroupTime]: @1};

NSUInteger itemToSelect = [self isCapturedEntriesContainClienst] ? 1 : self.menuItemsPostion[[NSNumber numberWithInteger:self.selectedGroup]]; // Incompatible operand types ('NSUInteger' (aka 'unsigned long') and 'id _Nullable')
我从
NSDictionary
中了解该方法

-(可空id)objectForKey:(id)键
可以返回可为null的对象,这就是问题所在


我对如何解决这个问题感兴趣

您必须获得对象的
integerValue
,才能将
itemToSelect
分配给
NSUInteger

NSUInteger itemToSelect = [self isCapturedEntriesContainClienst] ? 1 : [self.menuItemsPostion[[NSNumber numberWithInteger:self.selectedGroup]] integerValue];

您必须获取对象的
integerValue
,才能将
项指定给您的
itemToSelect
,即
NSUInteger

NSUInteger itemToSelect = [self isCapturedEntriesContainClienst] ? 1 : [self.menuItemsPostion[[NSNumber numberWithInteger:self.selectedGroup]] integerValue];

Thx我完全忘了这个是的,它更好:)Thx我完全忘了这个是的,它更好:)