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 Tools & Utilities

Reply
 
LinkBack Thread Tools Display Modes
Old 01-30-2011, 11:41 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 1
plastics is on a distinguished road
Default problem with acquiring data on selected cell in didSelectRowAtIndexPath

Hi I'm fairly new to this SDK programming and am having a problem getting the data of the selected cell with this code populated from a plist. I've spent a few days trying to make it work and can't figure out what I need to do differently, so any help would be very much appreciated.

Code:
@implementation FlipsideViewController


@synthesize delegate;
@synthesize keys;
@synthesize names;

#pragma mark -
#pragma mark View lifecycle


- (void)viewDidLoad {
    [super viewDidLoad];
	self.view.backgroundColor = [UIColor redColor];      

	
	self.title = @"Anaesthetic";
	
	
		
	NSString *path = [[NSBundle mainBundle] pathForResource:@"TOC" ofType:@"plist"];
	
	NSDictionary *dict = [[NSDictionary alloc]
                          initWithContentsOfFile:path];
    self.names = dict;
	NSLog(@"Log names: %@", names);
	
    [dict release];
	
    NSArray *array = [[names allKeys] sortedArrayUsingSelector:
                      @selector(compare:)];
    self.keys = array;
	NSLog(@"Log keys: %@", keys);
	
	
	
	[array release];

#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [keys count];
}

- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section {
    NSString *key = [keys objectAtIndex:section];
    NSArray *nameSection = [names objectForKey:key];
    return [nameSection count];
	
}

- (UITableViewCell *)tableView:(UITableView *)tableView
		 cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSUInteger section = [indexPath section];
    NSUInteger row = [indexPath row];
	
    NSString *key = [keys objectAtIndex:section];
    NSArray *nameSection = [names objectForKey:key];
	
    static NSString *SectionsTableIdentifier = @"SectionsTableIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
							 SectionsTableIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc]
				 initWithStyle:UITableViewCellStyleDefault
				 reuseIdentifier:SectionsTableIdentifier] autorelease];
    }
	
    cell.textLabel.text = [nameSection objectAtIndex:row];
	NSString *cellText = [nameSection objectAtIndex:row];
	NSLog(@"Log cellText: %@", cellText);

	return cell;
}

#pragma mark -
#pragma mark Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

	NSUInteger section = [indexPath section];
    NSUInteger row = [indexPath row];
	
    NSString *key = [keys objectAtIndex:section];
    NSArray *nameSection = [names objectForKey:key];
	NSString *selectedCell = [nameSection objectAtIndex:row];
	NSLog(@"Log selectedCell: %@", selectedCell);
	
	
		
	
	//NSInteger dose = [rowData objectForKey:@"Dose"];
	CalculatorViewController *calculatorViewController = [[CalculatorViewController alloc] initWithNibName:@"Lignocaine" bundle:nil];
	// ...
	// Pass the selected object to the new view controller.
	[self.navigationController pushViewController:calculatorViewController animated:YES];
Attached Images
File Type: jpg TOC plist screengrab.jpg (19.1 KB, 3 views)

Last edited by plastics; 01-30-2011 at 11:53 AM. Reason: adding a copy of the plist
plastics is offline   Reply With Quote
Reply

Bookmarks

Tags
uitableview problem, uitableviewcell

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: 413
11 members and 402 guests
AppleDev, chemistry, Emy, Gi-lo, ipodphone, mistergreen2011, pipposanta, QuantumDoja, Retouchable, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,129
Posts: 402,924
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

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