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 06-15-2008, 04:08 PM   #1 (permalink)
New Member
 
Join Date: May 2008
Posts: 33
bronxbomber92 is an unknown quantity at this point
Default Feeding data to UITableView

How do I get my tableview's cells to display the data I want it to?

This is what I've done:
1.) Create a UIViewController subclass
2.) Have the subclass conform to the UITableViewDelegate and UITableViewDataSource protocols.
3.) Add a IBOutlet that is a UITableView
4.) Created a view XIB. In this I have made the file owner's the subclass class. Then I added a UITableView.
5.) Make the connection so that UITableView's delegate and dataSource is the File's Owner (ie, the UIViewController subclass).
6.) Then in code, I have this:
Code:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
	return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
	if(displayLocalScores)
	{
		AppDelegate* appDel = (AppDelegate*)[[UIApplication sharedApplication] delegate];
		return [appDel.highScores count];
	}
	return 0;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	
	static NSString *MyIdentifier = @"High Score";
	
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
	if (cell == nil) {
		cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
	}
	// Configure the cell
	AppDelegate* appDel = (AppDelegate*)[[UIApplication sharedApplication] delegate];
	HighScore* cellData = [appDel.highScores objectAtIndex:indexPath.row];
	NSLog(@"Setting cell stuff");
	cell.text = [NSString stringWithFormat:@"%@: @i", cellData.username, cellData.score];
	return cell;
}

- (void)viewWillAppear:(BOOL)animated
{
	[highScoreTableView reloadData];
	[super viewWillAppear:animated];
}
I can't understand why the cells don't display the string I give it :/
bronxbomber92 is offline   Reply With Quote
Old 06-15-2008, 08:18 PM   #2 (permalink)
New Member
 
Join Date: May 2008
Posts: 33
bronxbomber92 is an unknown quantity at this point
Default Re: Feeding data to UITableView

I figured it out XD... displayLocalScores boolean was set to NO. Stupid mistake on my part :P
bronxbomber92 is offline   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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting data from an UIImage realberen iPhone SDK Development 12 04-17-2012 12:46 AM
pixel data iamdave iPhone SDK Development 2 08-12-2008 08:38 PM
Data lost between tableviews martinn iPhone SDK Development 5 06-16-2008 11:52 AM
Transfering data to/from Mac/PC ? jdelgoulet iPhone SDK Development 1 04-29-2008 08:35 AM
Pulling Data From A Web Page CoffeeKid iPhone SDK Development 8 04-17-2008 11:43 AM


» Advertisements
» Online Users: 340
3 members and 337 guests
guusleijsten, Kryckter, LEARN2MAKE
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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