Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Table View organization into Alphabetical sections

greeneye82greeneye82 Posts: 20Registered Users
ok, onto my next dilemma. I've done a ton of Googling and it seems there are several ways to go about it, but none seem to fit my structuring of my table view. I'm using Xcode 4.3.2 with ARC and storyboards. I have a plain view table view. My table consists of a list of cities and their departments (one city for each row), when the user selects a city they will be pushed to a detail view of about that city. I want to organize my table alphabetically, with a section header. Any recommendations, hints, links to tutorials, would be greatly appreciated.

I have a NSMutable array set up like this in my table view .m

NSMutableArray *dept;   


- (void)viewDidLoad

{
[super viewDidLoad];

dept = [[NSMutableArray alloc] init];

City *thedept = [[City alloc] init];
[thedept setCityname:@\"Albany\"];
[thedept setPhone:@\"5551237890\"];
[dept addObject:thedept];

thedept = [[City alloc] init];
[thedept setCityname:@\"Boston\"];
[thedept setPhone:@\"5556543435\"];
[dept addObject:thedept];

thedept = [[City alloc] init];
[thedept setCityname:@\"Springfield\"];
[thedept setPhone:@\"5553456323\"];
[dept addObject:thedept];

thedept = [[City alloc] init];
[thedept setCityname:@\"Tallahassee\"];
[thedept setPhone:@\"5552450988\"];
[dept addObject:thedept];

thedept = [[City alloc] init];
[thedept setCityname:@\"Vacouver\"];
[thedept setPhone:@\"5551312555\"];
[dept addObject:thedept];


The section header can just be the letter of the alphabet (A, B, C, D...). I'm thinking I need to pre-organize my cities by their first letter and maybe name the section based on the letter (such as "sectionAcities"). The cities I have given are just a few, I have about 100 total.
Post edited by greeneye82 on

Replies

Sign In or Register to comment.