鍵我願做這樣的事情:使用「生成的字符串」(stringWithFormat)作爲NSDictionary的
#define GETKEY (a) ([NSString stringWithFormat:@"%d",a])
NSMutableDictionary *mutableDictionay=[NSMutableDictionary dictionary];
//population of dictionary
[mutableDictionary setObject:anObject forKey:GETKEY(someIntValue)];
//... then retrive the object
[mutableDictionary getObjectForKey:GETKEY(someIntValue)];
但我擔心的stringWithFormat方法返回的NSString的不同實例具有相同值,我的意思是喜歡有2個字符串:「0」和另一個值爲「0」的實例。我想知道這個是一種安全的方式來獲取和設置字典中的對象。如果沒有,什麼其他方式可能是從一個整數「生成」一個關鍵對象的最佳方式?