Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 11-29-2010, 04:00 AM   #5 (permalink)
deannerene
Registered Member
 
Join Date: Nov 2010
Location: Calabasas, Ca
Posts: 22
deannerene is on a distinguished road
Default

Quote:
Originally Posted by raheel View Post
Hi guys,

I've got a situation, where i have to add sections to a tableview.
An NSMutableArray is having objects with anNSInteger Type and NSString title.


Code:
ExOb *eob = (ExOb *)[appDelegate.ExArray objectAtIndex:indexPath.row];
want i want to do is,
if (eob.Type == 1){
//add to indexpath.section 1
} else if (eob.Type == 2){
//add to section 2
}
else if (eob.Type == 1){
//add to section 3
}

however, i can actually implement this cuz i simply dont kno how to.
and also, to return the exact number of rows where eob.type==1.. etc

Most examples have arrays for each sections.

any suggestions would be great

I had done something similar before and a quick test shows that it should work for you.

In the :
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
you need to create a new index like this:

Code:
int matchingIndex = ((indexPath.section *2)+ indexPath.row);
This tracks with a group of 2 rows per section. If your sections have a different number of rows then adjust the multiplier for that.

Of course if your sections have varying row counts the math doesn't work. It worked for me.

Deanne
deannerene is offline   Reply With Quote
 

» Advertisements
» Online Users: 406
17 members and 389 guests
askb, Chickenrig, Code.ei, dansparrow, dre, guillermotricia, ilmman, JavierEPease, jaychoupham, LEARN2MAKE, n00b, NSString, pbart, roof44, Speed, teebee74, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,591
Threads: 94,083
Posts: 402,777
Top Poster: BrianSlick (7,990)
Welcome to our newest member, guillermotricia
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:26 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.