In my app I have a requirement like saving the data in itemsArray in the following format like
iPhone
iPad
iPod Touch
and the same data I am tryin to display in the UITableView
but it is taking only the first item i.e iPhone
It is not displaying the remaining items in the itemsArray.
I have been trying this but I am not able to find the solution for it.
Can anyone please help me to solve this.
I am new to Objective C.
Thanks in Advance.
If you want all 3 items in single cell then create one dictionary as follows:
NSMutableArray * contentsArray = [NSMutableArray array];
NSMutableDictionary * allContacts = [NSMutableDictionary dictionary];
for(int i = 0; i < yourItemArrayCount; i++) {
[allContacts setObject:[yourItemArray objectAtIndex:i] forKey:@"key %@",[[youtItemArray objectAtIndex:i] stringValue]];
}
[contentsArray addObject:allContacts];
then in following method
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//Write your dictionary logic here
NSDictionary *dict = [contentsArray objectAtIndex:indexpath.row];
//Necessary logic will go here.
}
Add following method in your code
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 60; //You can set height of cell here.
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments