IOS 自定义tableview滑动报错
-(void)viewDidLoad{[superviewDidLoad];NSArray*datarray=[NSArrayarrayWithContentsOfFil...
- (void)viewDidLoad
{
[super viewDidLoad];
NSArray *datarray=[NSArray arrayWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"dianhangjia.plist" ofType:nil]];
_mydatas=[NSMutableArray array];
for (NSDictionary *dict in datarray) {
[_mydatas addObject:[MyModel weiboweithDict:dict]];
}
NSLog(@"%@",datarray);
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return _mydatas.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//去缓存池取出cell
static NSString *ID=@"weibo";
MyCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
//缓存没有cell,重新创建cell
if (cell==nil) {
cell=[[MyCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
}
//cell.textLabel.text=@"这是内容";
cell.mymodel=_mydatas[indexPath.row];
return cell;
}
@implementation MyModel
-(id)initWithDict:(NSDictionary *)dict{
if(self=[super init]){
self.faceico=dict[@"faceico"];
self.username=dict[@"username"];
self.anwsercount=dict[@"anwsercount"];
self.guanzhucount=dict[@"guanzhucount"];
self.tagscontent=dict[@"tagscontent"];
}
return self;
}
//将字典转换为模型
+(id)weiboweithDict:(NSDictionary *)dict{
return [[self alloc]initWithDict:dict];
}
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndexedSubscript:]: unrecognized selector sent to instance 0x743f9f0'
*** First throw call stack:
(0x1fa6012 0x13e3e7e 0x20314bd 0x1f95bbc 0x1f9594e 0x3348 0xd28fb 0xd29cf 0xbb1bb 0xcbb4b 0x682dd 0x13f76b0 0x25a2fc0 0x259733c 0x2597150 0x25150bc 0x2516227 0x25168e2 0x1f6eafe 0x1f6ea3d 0x1f4c7c2 0x1f4bf44 0x1f4be1b 0x1f007e3 0x1f00668 0x17ffc 0x2422 0x2355) 展开
{
[super viewDidLoad];
NSArray *datarray=[NSArray arrayWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"dianhangjia.plist" ofType:nil]];
_mydatas=[NSMutableArray array];
for (NSDictionary *dict in datarray) {
[_mydatas addObject:[MyModel weiboweithDict:dict]];
}
NSLog(@"%@",datarray);
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return _mydatas.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//去缓存池取出cell
static NSString *ID=@"weibo";
MyCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
//缓存没有cell,重新创建cell
if (cell==nil) {
cell=[[MyCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
}
//cell.textLabel.text=@"这是内容";
cell.mymodel=_mydatas[indexPath.row];
return cell;
}
@implementation MyModel
-(id)initWithDict:(NSDictionary *)dict{
if(self=[super init]){
self.faceico=dict[@"faceico"];
self.username=dict[@"username"];
self.anwsercount=dict[@"anwsercount"];
self.guanzhucount=dict[@"guanzhucount"];
self.tagscontent=dict[@"tagscontent"];
}
return self;
}
//将字典转换为模型
+(id)weiboweithDict:(NSDictionary *)dict{
return [[self alloc]initWithDict:dict];
}
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndexedSubscript:]: unrecognized selector sent to instance 0x743f9f0'
*** First throw call stack:
(0x1fa6012 0x13e3e7e 0x20314bd 0x1f95bbc 0x1f9594e 0x3348 0xd28fb 0xd29cf 0xbb1bb 0xcbb4b 0x682dd 0x13f76b0 0x25a2fc0 0x259733c 0x2597150 0x25150bc 0x2516227 0x25168e2 0x1f6eafe 0x1f6ea3d 0x1f4c7c2 0x1f4bf44 0x1f4be1b 0x1f007e3 0x1f00668 0x17ffc 0x2422 0x2355) 展开
1个回答
2014-05-29
展开全部
这个太专业了,最好还是找专业的人吧
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询