Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 591117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:36:04+00:00 2026-05-13T15:36:04+00:00

I’m pretty new to Objective C and iPhone development and have hit a problem

  • 0

I’m pretty new to Objective C and iPhone development and have hit a problem which has completely stumped me

I have a class, Sale, which has the following class method:

+(NSMutableArray*)liveSales {
NSMutableArray *liveSales = [[NSMutableArray alloc] init];

for(int i = 0; i <= 100; i++)
{
    Sale *s = [[Sale alloc] init];
    //[s setTitle:[NSString stringWithFormat:@"Sale %d", i+1]];
    [s setTitle:@"Title"];
    //[s setDescription:[NSString stringWithFormat:@"Sale %d descriptive text", i+1]];
    [s setDescription:@"Description"];

    [liveSales addObject:s];

    [s release];
    s = nil;
}

return [liveSales autorelease];

}

I’m then using this class method in the following way:

#import "RootViewController.h"
@implementation RootViewController
@synthesize liveSales = _liveSales;


- (void)viewDidLoad {
    [super viewDidLoad];

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;

    [[self navigationItem] setTitle:@"Sales"];

    if (![self liveSales]) 
    {
        [self setLiveSales:[Sale liveSales]];
    }

}

I then customise my table cells using the following event:

// Customize the appearance of table view cells.
- (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];
    }

    // Configure the cell.
    Sale *sale = [[self liveSales] objectAtIndex:[indexPath row]];

    [[cell textLabel] setText:[sale title]];
    [[cell detailTextLabel] setText:[sale description]];

    [sale release];
    sale = nil;

    return cell;
}

If I then run this code using the Simulator I can see that each table cell shows the correct information and everything appears to be working correctly, that is until I scroll to the very bottom of the list and the application dies with the following information recorded in the console window:

2010-02-10 20:23:50.741 AppName[1828:207] *** -[UICGColor title]: unrecognized selector sent to instance 0x3b05750
2010-02-10 20:23:50.743 AppName[1828:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UICGColor title]: unrecognized selector sent to instance 0x3b05750'
2010-02-10 20:23:50.744 AppName[1828:207] Stack: (
    29291611,
    2510427401,
    29673531,
    29242998,
    29095618,
    8789,
    3047008,
    3013271,
    3089642,
    3053907,
    55804592,
    55804015,
    55802054,
    55801146,
    55834680,
    29078098,
    29075039,
    29072456,
    37382029,
    37382226,
    2764803
)

I’ve spent a good few hours trying to work out what’s going on here to no avail but I’m sure I’m either missing something really obvious, or approaching the logic of the application in the wrong way

Any help anyone could provide would be greatly appreciated 🙂

Thanks

Dave

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:36:05+00:00Added an answer on May 13, 2026 at 3:36 pm

    You make an extra release in:

    // Configure the cell.
    Sale *sale = [[self liveSales] objectAtIndex:[indexPath row]];
    
    [[cell textLabel] setText:[sale title]];
    [[cell detailTextLabel] setText:[sale description]];
    
    [sale release];
    sale = nil;
    

    sale is an autoreleased instance obtained from an array, don’t release it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.