Results 1 to 2 of 2
  1. #1

    Member Since
    Jun 09, 2010
    new to objective c - help with tiny problem
    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:

    -(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!

  2. #2

    xstep's Avatar
    Member Since
    Jun 25, 2005
    On the road
    2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
    I would do an NSLog on the entryName like so;
    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:

    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. tiny lettering
    By joancmck in forum Switcher Hangout
    Replies: 2
    Last Post: 08-21-2014, 04:16 PM
  2. Tiny thumbnails
    By colinhawkes103 in forum Switcher Hangout
    Replies: 6
    Last Post: 08-09-2014, 01:32 PM
  3. New to Objective C - what is the problem with this?
    By rb1383 in forum macOS - Development and Darwin
    Replies: 1
    Last Post: 04-22-2009, 12:33 AM
  4. Replies: 9
    Last Post: 04-10-2009, 11:15 PM
  5. tiny icon
    By heey in forum macOS - Operating System
    Replies: 4
    Last Post: 09-02-2008, 11:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts