特定のインデックスにオブジェクトを挿入したい。インデックスにオブジェクトがない場合、それを知りたいです。NSDictionary は良い選択ですか? 別の良い解決策はありますか?
// Initailization
NSMutableDictionary *items = [NSMutaleDictionary dictionary];
...
// insert an object.
[items setObject:item forKey:[NSNumber numberWithInt:3]];
...
// I want to know that there is an object at a given index.
item = [items objectForKey:[NSNumber numberWithInt:4]];
if (item)
// exist
else
// non exist