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

sdkIQ for iPhone
($4.99)

Your First iPhone App
($1.99)

iPhone Code Generator
($9.99)

Dual Matches
($0.99)

Calcuccino Programmers' Calculator
($2.99)

SDKtoday
(free)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-11-2010, 07:11 PM   #1 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 80
Default tableView sections with data from a single array object

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
raheel is offline   Reply With Quote
Old 01-11-2010, 07:36 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: Loveland, OH
Age: 35
Posts: 3,139
Default

There is a reason most examples do that. Is there a reason that you can't?
__________________
My Company: BriTer Ideas LLC
My Services: Code review, consulting, development. PM for details.
My App: SlickShopper

Free NSLog utility

Ways to thank me: Buy my app. Leave a PayPal donation.

Things I've Written That You Should Read:
Definitive Guide To Properties | iPhone Development Resources, Tips, and Tricks | UITableView Series (Last update: 2/24)
BrianSlick is online now   Reply With Quote
Old 01-11-2010, 07:42 PM   #3 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 80
Default

no reason actually. I'd hav to initialise about 4 arrays in viewdidload, add them to dictionary. and then add all those to a single array.

I was just thinking if theres an easier way, the data is huge, many cells. I was looking for a memory saving way out
raheel is offline   Reply With Quote
Old 01-11-2010, 07:49 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: Loveland, OH
Age: 35
Posts: 3,139
Default

You'd have the same amount of data either way, right? The memory for the containers themselves would be relatively small.

I guess it depends on how you define "easier". I personally keep a master list of data, and then have a sorting routine that breaks it down into smaller parts. My table view methods only care about the smaller parts; they don't care how the data was sorted.

Here is something that should help:
Clinging To Ideas: Taming Table Views

After I wrote that, I learned that CoreData has a NSFetchedResultsSectionInfo class which is basically the same thing, so I think I'm on the right track.

And you only "need" 2 arrays: master and sorted.
__________________
My Company: BriTer Ideas LLC
My Services: Code review, consulting, development. PM for details.
My App: SlickShopper

Free NSLog utility

Ways to thank me: Buy my app. Leave a PayPal donation.

Things I've Written That You Should Read:
Definitive Guide To Properties | iPhone Development Resources, Tips, and Tricks | UITableView Series (Last update: 2/24)
BrianSlick is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


» Advertisements
» Stats
Members: 41,862
Threads: 49,772
Posts: 213,060
Top Poster: BrianSlick (3,139)
Welcome to our newest member, futurevilla216
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:08 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0