我有一個indexPath.row是1並記錄1(當使用NSLog時)。如果我叫indexPath.row-1(應返回0),它返回4294967295indexPath.row-1是4294967295
我試圖返回objectAtIndex:indexPath.row-1
,但那個時候我拿到4294967295
任何想法?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
Singleton *singleton = [Singleton sharedSingleton];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if ([[prefs objectForKey:@"isYes"]boolValue] == 1 && randomMarker != 100)
{
//sets cell image
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,98,100)];
imgView.image = [UIImage imageNamed:@"stackoverflow.png"];
cell.imageView.image = imgView.image;
//sets cell text
cell.textLabel.text = @"Text";
self.checkedInCount == 100;
}
else if ([[prefs objectForKey:@"isYes"]boolValue] == 1 && randomMarker == 100)
{
//gets cell and cleans up cell text
NSLog(@"%@", indexPath.row);
NSString *title = [[[singleton linkedList]objectAtIndex:(indexPath.row-1)]objectForKey:@"desc"];
我的猜測是,你實際上試圖得到objectAtIndex:-1,這是無稽之談。將代碼發佈到正在發生的位置以獲得更具體的幫助。 – PengOne
NSString * tempDesc = [[[singleton linkedList] objectAtIndex:indexPath.row-1] objectForKey:@「desc」]; – Baub
它在這條線上崩潰,聲明索引4294967295超出範圍(0,0) – Baub