0

我正在尝试从存储在字典中的数组中删除一个对象。我已经能够使用以下代码按索引删除对象:

[compHandHighValuesArray removeObject:[NSNumber numberWithInt:[[highCardDictionary    valueForKey:[cardsShuffled objectAtIndex:1]] intValue]]];

但是现在我想将 [cardsShuffled objectAtIndex:1] 更改为 ID 变量。当我将代码替换为:

[compHandHighValuesArray removeObject:[NSNumber numberWithInt:[[highCardDictionary valueForKey:[compCardOneTitle]] intValue]]];

我收到“预期标识符”的错误。我错过了什么?

4

1 回答 1

1

这个:

[highCardDictionary valueForKey:[compCardOneTitle]]

不是有效的语法。我想那compCardOneTitle是你的ID,但你没有说 anID是什么......

如果ID是一个字符串/键,那么你应该有:

[highCardDictionary valueForKey:compCardOneTitle]
于 2013-10-17T20:39:51.747 回答