2011-01-07 72 views
2

我在.h文件中初始化實例變量,NSMutableArray的問題?

NSInteger saveValue0,saveValue1,saveValue2,saveValue3;

NSMutableArray * nodeArray;

現在.m文件,在viewWillAppear中事件,

saveValue0 = 0; 
saveValue1 = 2; 
saveValue2 = 3; 
saveValue3 = 0; 

nodeArray = [[NSMutableArray alloc] initWithObjects:saveValue0, saveValue1, saveValue2, saveValue3, nil]; 

但是上述變量不陣列中插入。當我試圖看到使用斷點的數組中的對象時,它給了我0個存在於nodeArray中的對象。爲什麼它會給我0個對象。背後的任何理由?

回答

2

NSInteger不是一個對象,只能將對象存儲在數組中。使用[的NSNumber numberWithInteger:0]等

+0

毫不奇怪,這也產生一個編譯器警告:「警告:傳遞的參數1 'initWithObjects:'使整數指針沒有演員「我想知道爲什麼RRB沒有提及? – 2011-01-07 10:00:47

0

NSInteger的僅僅是一個標準的C type.U不能添加這些成的NSMutableArray