我有一個for循環的問題 我把一個NSArray放入tableview中,我希望最後一個對象在第一個單元格中,但是它只能在第一個對象中使用,NSArray循環問題
這個工程:
for(int i = 0; i < messages.count ; i++)
{
}
但這並不:
for(int i = messages.count; i > 0; i--)
{
}
和錯誤消息是:
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 203 beyond bounds [0 .. 202]'
*** First throw call stack:
(0x32bd33e7 0x3a8c4963 0x32b1eef9 0x891d3 0x34a01579 0x34a561f7 0x34a5613d 0x34a56021 0x34a55f4d 0x34a55699 0x34a55581 0x34a26561 0x349e58c7 0x34791513 0x347910b5 0x34791fd9 0x347919c3 0x347917d5 0x349eb93f 0x32ba8941 0x32ba6c39 0x32ba6f93 0x32b1a23d 0x32b1a0c9 0x366f833b 0x34a362b9 0x8549d 0x3acf1b20)
libc++abi.dylib: terminate called throwing an exception
的for(int i = messages.count - 1; I> = 0 ; i--) - 數組從零開始 – VMAtm 2013-07-21 21:04:38