I have custom object and I have stored my values in Array. but I am bit stuck to show objects values form array. My code definition is here.
for (int i = 0; i < 20; i++)
{
Person *myPerson = [[Person alloc] init];
myPerson.name = @"Brian";
myPerson.age = [NSNumber numberWithInteger:23];
[myArray addObject:myPerson];
[myPerson release];
}
Now I want to show all 20 values which is stored in Array (name and age of person).
How will I show that values?
There are many different ways of showing the customers depending on what you want.
1. Print to the console
If you just want to print them out to the console, you can use:
additionally, you can use Fast Enumerators to neaten things up:
2. Showing in a table view
You’ll need a
UITableViewwith an instance ofUITableViewControllerthat conforms to theUITableViewDataSourceprotocol.This tutorial gives you an excellent walkthrough:
http://www.icodeblog.com/2008/08/08/iphone-programming-tutorial-populating-uitableview-with-an-nsarray/
If neither of these solutions suits, please provide more information about what you’re trying to achieve.