New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

new to objective c - help with tiny problem


Post Reply New Thread Subscribe

 
Thread Tools
natronp

 
Member Since: Jun 09, 2010
Posts: 1
natronp is on a distinguished road

natronp is offline
having trouble finding documentation showing how to utilize an object's properties to set the text label for a cell within UITableView's cellForRowAtIndexPath method:

Code:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
	if(cell == nil) {
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"] autorelease];
	}
	
//a temporary representation of a class object from an array	
tempObj = [[ItemEntry alloc] init];
	tempObj = [entries objectAtIndex:[indexPath row]];
				  
				  
	//this doesn't work and i'm not sure why...
	[[cell textLabel] setText:[tempObj.entryName]];

	[tempObj release];
	tempObj = nil;
	
	return cell;

	
}
Any help straightening out this total noob is appreciated!
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
I would do an NSLog on the entryName like so;
Code:
NSLog(@"[tempObj.entryName] %@", [tempObj.entryName]);
This allows you see what that text contains, if anything.


I don't see a need to allocate and release tempObj either. All you care about here is the pointer, not recreating the whole object from your array. So I think the following is fine for the affect 5 lines:

Code:
id tempObj = [entries objectAtIndex:[indexPath row]];
[[cell textLabel] setText:[tempObj.entryName]];
Note that you likely want to replace 'id' with the appropriate class name and pointer symbol '*'.

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks

Post Reply New Thread Subscribe


« Simple question, If greater than x and less than y, how? #Applescript | two NSArrayControllers »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Problem With Keyboard...... mmcltd OS X - Operating System 4 02-02-2010 06:47 PM
Possible faulty CPU thermometer, common problem? dyaballikl Apple Notebooks 6 11-16-2008 12:21 AM
Microsoft Messenger Problem millenium_spike OS X - Apps and Games 4 09-16-2008 01:11 AM
Problem Darwin Server + VLC nanaki Web Design and Hosting 0 03-13-2008 07:27 AM
Problem with ethernet board after installing RAM and upgrading from 10.2.8 to 10.3.5 ydonofrio Apple Desktops 4 02-11-2008 07:16 PM

All times are GMT -4. The time now is 11:23 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?