我对此很新,所以请原谅我的无知。IOS将数据从Web服务加载到表中
我有以下方法拼凑在一起,运行时没有错误,并验证了我从Web服务获取数据。我注意到的是,当我在numberOfRowsInSection方法上放置一个断点时,它同时返回0。我假设这意味着我没有正确加载我的数组。
声明我的消息属性的报头
@property (nonatomic, strong) NSArray *messages;
合成,在M档属性
@synthesize messages;
这是加载的数据,并假定重新加载表
该方法这个是我告诉它如何加载单元格的方法- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MessageCell"];
EHRXMessage *message = [self.messages objectAtIndex:indexPath.row];
cell.textLabel.text = message.callback_name;
cell.detailTextLabel.text = message.subject;
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.messages count];
}
这里是一个什么样的JSON看起来像
{"result":"success","count":"0", "messages":[{"SenderID":"6fcb7c19-b21f-4640-a237-0e7ac5ca0ce8","Title":"General","Message":"","CallbackName":"Claudia","CallbackNumber":"1295","EncounterID":null,"AdmissionID":"d7387243-3e8a-42e4-8a85-fdd3428dae68","DateSent":"3/9/2012 12:52 PM"}]}
是它做什么?或者只是不显示表中的数据? – 2012-03-13 21:35:10
它一路通过,但表从不更新,我添加了一个警报来验证。 – Jhorra 2012-03-13 21:41:54
你可以NSLog message.callback_name或者你知道它被正确的分配吗? – 2012-03-13 22:33:53