當我加載一個UITableView它訪問numberOfSectionsInTableView:兩次並崩潰應用程序與「EXC_BAD_ACCESS」。我從來沒有經歷過這個。UITableView訪問mberOfSectionsInTableView兩次並崩潰
應該在執行tableview的初始加載時訪問兩次numberOfSectionsInTableView?
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
NSLog(@"numberOfSectionsInTableView");
// Return the number of sections.
NSLog(@"Count: %i", [self.playerArray count]);
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"numberOfRowsInSection");
// Return the number of rows in the section.
NSLog(@"time for return");
return [self.playerArray count];
}
響應是:
2010-11-20 19:35:06.459 FamQuiz_v2 [10151:207] numberOfSectionsInTableView
當前語言:汽車;目前目標c
2010-11-20 19:35:12.408 FamQuiz_v2 [10151:207]計算:2
(GDB)繼續
2010-11-20 19:35:28.918 FamQuiz_v2 [10151:207] numberOfSectionsInTableView
編程接收信號:「EXC_BAD_ACCESS」。
編程接收信號:「EXC_BAD_ACCESS」。
}
我確實在[numberOfSectionsInTableView]中放置了[playerArray retain],它工作正常。我猜想原因是它被訪問了兩次。 – PeterK 2010-11-20 21:53:27
A BIG謝謝你,在這個論壇上的人是驚人的:-) – PeterK 2010-11-20 22:05:05
這可能不是你保留的正確位置。檢查它在創建時是否保持正確。 – TomSwift 2010-11-20 22:28:40