I m trying to fetch data from server and want to display it on the table view. My cell is custom cell.. Custom tableviewCell has labels and buttons. Now, i have 3 classes .
1..invoiceCell(sub class of tableviewCell) - In this class i have outlets of lables.
@property (weak, nonatomic) IBOutlet UILabel *lblID;
@property (weak, nonatomic) IBOutlet UILabel *lbldate;
@property (weak, nonatomic) IBOutlet UILabel *lblduedate;
@property (weak, nonatomic) IBOutlet UILabel *lblamount;
@property (weak, nonatomic) IBOutlet UILabel *lblstatus;
2.invoiceObject.h(sub class of nsobject) - in this class I have @properties...
@property (nonatomic) int *ID;
@property (nonatomic,strong) NSString *date;
@property (nonatomic,strong) NSString *total;
@property (nonatomic,strong) NSString *duedate;
@property (nonatomic,strong) NSString *status;
-(instancetype)initWithid :(int)ID andDate :(NSString *)idate andTotal :(NSString *)itotal andDuedate :(NSString *)iduedate andStatus :(NSString *)istatus;
invoiceObject.m
-(instancetype)initWithid :(int)ID andDate :(NSString *)idate andTotal :(NSString *)itotal andDuedate :(NSString *)iduedate andStatus :(NSString *)istatus
{
self = [super init];
if(self)
{
self.ID = ID;
self.date = idate;
self.total = itotal;
self.duedate = iduedate;
self.status = istatus;
}
return self;
}
3.invoiceTV(sub class of tableViewController) ... identifier name "Cell".
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:@"http:/
NSData *jsondata = [NSData dataWithContentsOfURL:url];
NSDictionary *dataDictionary = [NSJSONSerialization
JSONObjectWithData:jsondata options:0 error:nil];
for (NSDictionary *bpDictionary in dataDictionary)
{
innvoiceObject *currenInvoice = [[innvoiceObject alloc] initWithid:[bpDictionary objectForKey:@"id"] andDate:[bpDictionary objectForKey:@"invoicedate"] andTotal:[bpDictionary objectForKey:@"total"] andDuedate:[bpDictionary objectForKey:@"duedate"] andStatus:[bpDictionary objectForKey:@"status"]];
[self.objectHolderArray addObject:currenInvoice];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
-(NSMutableArray *)objectHolderArray
{
if(!_objectHolderArray) _objectHolderArray = [[NSMutableArray alloc]init];
return _objectHolderArray;
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.objectHolderArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath
{
NSString *CellIdentifier = @"Cell";
invoiceCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier
];
innvoiceObject *currentInvoice = [self.objectHolderArray
objectAtIndex:indexPath.row];
cell.lblID.text = [NSString stringWithFormat:@"%d",currentInvoice.ID];
cell.lbldate.text = currentInvoice.date;
cell.lbldate.text = currentInvoice.duedate;
cell.lblamount.text = currentInvoice.total;
cell.lblstatus.text = currentInvoice.status;
return cell;
}
I had tried this way But m not getting any response in table view its shows me empty table view in simulator. When i m trying to debug it shows tableView with no data in it. And console is also blank when i debug..I m trying this since 3,4 days.. please help!!
thank U in advance....