I am getting data using this way from i want that i should display date in section title and the event location in rows which are in appDelegate.book1 array. when this roop runs first then in first section it must show 7 rows in one section and same like that as come but i am not getting required
NSArray *activitiesArray;
for (int j=0;j<10; j++) {
NSDictionary *dictOne = [results objectAtIndex:j];
NSLog(@"%@ - %@", [dictOne objectForKey:@"date"]);
Date *aDate = [[Date alloc] initWithDictionary:[results objectAtIndex:j]];
[appDelegate.dates addObject:aDate];
[aDate release];
activitiesArray = [dictOne objectForKey:@"events"];
for (int i=0; i<[activitiesArray count]; i++) {
int testcount =[activitiesArray count];
NSDictionary *dictTwo = [activitiesArray objectAtIndex:i];
NSDictionary *eventDict=[dictTwo objectForKey:@"event"];
// NSLog(@"%@ - %@", 开发者_Go百科[dictOne objectForKey:@"date"]);
// NSLog(@"%@ - %@", [dictTwo objectForKey:@"affectedDate"]);
// NSLog(@"%@ - %@", [eventDict objectForKey:@"location"]);
NSInteger*date=[dictTwo objectForKey:@"affectedDate"];
NSInteger*affectedDate=[dictTwo objectForKey:@"affectedDate"];
NSString*appId =[eventDict objectForKey:@"appId"];
NSString*eventId=[eventDict objectForKey:@"eventId"];
NSString*location=[eventDict objectForKey:@"location"];
NSString*municipality=[eventDict objectForKey:@"municipality"];
NSString*title=[eventDict objectForKey:@"title"];
Book1 *aBook=[[Book1 alloc] initWithDate:date affectedDate:affectedDate location:location municipality:municipality title:title];
[appDelegate.books1 addObject:aBook];
int count=[appDelegate.books1 count];
}
}
this is the NSLog of count of appDelegate.book1 The value of integer num is 1 2011-08-09 12:40:31.731 FVN[2409:207] The value of integer num is 2 2011-08-09 12:40:31.731 FVN[2409:207] The value of integer num is 3 2011-08-09 12:40:31.731 FVN[2409:207] The value of integer num is 4 2011-08-09 12:40:31.732 FVN[2409:207] The value of integer num is 5 2011-08-09 12:40:31.732 FVN[2409:207] The value of integer num is 6 2011-08-09 12:40:31.733 FVN[2409:207] The value of integer num is 7
so like this array my table view should show 7 items in first section adn like wise above as they are in sequence so how to do this
I think you are looking for the following two delegate methods in your Table view controller subclass.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2; //return the actual number of sections you want
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
if(section == 0)
return 7; //actually return your array1's count
if(section == 1)
return 9; //actually return your array2's count
}
HTH,
Akshay
精彩评论