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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-20-2010, 04:36 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 60
racharambola5 is on a distinguished road
Default Split and swap string in Objective C (iphone)

Hi I have an array of strings separated with a delimeter ":". I tried separating strings using componentsSeparatedByString method and then save the result into an array and later use that array to produce the desired output, but it didn't worked.

For example

Now my UITableView displays cells as:

**Case 1:**

How:Many
Too:Many
Apple:Milk
iPhone:Simulator


I want the cells to be displayed on UITableView as:

**Case 2:**

Many How
Many Too
Milk Apple
Simulator iPhone

This is my cellForRowAtIndexPath method:

Code:
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        
        static NSString *CellIdentifier = @"Cell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }
    	NSString *entry=[entryKeys objectAtIndex:[indexPath section]];
        NSArray *entrySection=[entries objectForKey:entry];
    	  cell.textLabel.text=[entrySection objectAtIndex:[indexPath row]]
    	}
    	
    	return cell;
    }




The output of the above method is **case 1** but I want the output to be **case 2**
entryKeys has keys from A-Z and entry section has values sorted and listed for respective keys i.e. entries starting with A grouped under key A so on...

It may sound silly but I am still learning..please help me
racharambola5 is offline   Reply With Quote
Old 08-20-2010, 04:49 PM   #2 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 60
racharambola5 is on a distinguished road
Default

I fixed it!!!!
racharambola5 is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, nsstring, objective c, uitableview

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
» Online Users: 346
5 members and 341 guests
freewind, HemiMG, lendo, Newbie123, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,894
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:54 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0