i have a custom class called contact. This class has attributes like name, address etc.
I wish to create an array of type contact and display the value of each attibute in a custom cell in UItableview.
Code to store the data in array:
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
NSString *aName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
myContact.nm = aName;
NSString *aAddress = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
myContact.address = aAddress;
NSLog(@"%@",aName);
[list.details addObject:myContact];
NSLog(@"%@", list.details);
}
here details is an array declared as @property(nonatomic,retain)NSMutableArray *details; in .h
My question is that how do i retrieve the values on each index like :
[0]->name
[0]->address
[1]->name
[1]->address ....
my code in tableview.m:
cell.name.text = [details objectAtIndex:indexPath.row]; // not working
how do i solve this?
[details objectAtIndex:indexPath.row];returns theContactobject. What you need is,nmproperty ofContactobject which represents the name in your code.Try this,
Similarly you can get
[myContacts address]as well.Edit:
Based on your question in comments, the answer is: