我正在开发iPhone应用程序,创建了一个包含按钮和tableViewController的视图控制器,必须以sqlite3的形式显示数据,我正在使用xcode 3.4
我想要viewController中的按钮打开TableViewController,当我尝试不使用按钮打开该表本身时,我转到情节提要,将原始内容放到TableViewController中,并正常加载sqlite的数据
但是,当我将raw放在viewController上并将按钮连接到TableViewController并使连接成为模态然后运行..当我按下按钮时,它给了我以下异常:NSInvalidArgumentException', reason: '-[NSIndexPath isEqualToString:]: unrecognized selector sent to instance ...
并且异常引用(cellForRowAtIndexPath
)中的一行
这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
Books *temp= (Books *)[self.books objectAtIndex:indexPath.row];
// [cell setText:temp.bo_name];
[cell setText:[NSString stringWithFormat:@"%d - %@ - %d - %d - %d - %d - %@ - %f - %f - %@ - %f - %d - %@ - %d",temp.bo_id, temp.bo_name, temp.bo_au_id, temp.bo_pub_id, temp.bo_num_pages, temp.bo_publish_year, temp.bo_about, temp.bo_price, temp.bo_currency, temp.bo_cover_img, temp.bo_recomended, temp.bo_sec_id, temp.bo_path, temp.bo_sort]];
return cell;
}
编辑以添加在我的答案的注释-JeremyP中指定的实例变量的类型。
int bo_id;
NSString *bo_name;
int bo_au_id;
int bo_pub_id;
int bo_num_pages;
int bo_publish_year;
NSString *bo_about;
double bo_price;
double bo_currency;
NSString *bo_cover_img;
double bo_recomended;
int bo_sec_id;
NSString *bo_path;
int bo_sort;
最佳答案
setText
已过时。尝试使用[cell setText:[NSString stringWithFormat:@"%d...
代替
cell.textLabel.text =[NSString stringWithFormat:@"%d...
该错误可能在
%d - %@ - %d - %d - %d - %d - %@ - %f - %f - %@ - %f - %d - %@ - %d
长度的某处,导致参数不匹配(NSInvalidArgumentException
)。仔细遍历列表以找出错误。不查看单个元素的数据类型是很难分辨的。关于iphone - 当加载表包含来自sqlite3的数据时发生异常,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10191876/