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 9134371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:38:53+00:00 2026-06-17T08:38:53+00:00

I am a novice programmer. Already night trying to solve the problem, but did

  • 0

I am a novice programmer. Already night trying to solve the problem, but did not work. I’m trying to dynamically change the size of a cell based on the content of information. Do by example, but my program startup dies. With the error:

 'Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '-[__NSDictionaryI sizeWithFont:constrainedToSize:lineBreakMode:]"     

What am I doing wrong? Here is my code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] ;
    }

    NSDictionary *newsItem = [news objectAtIndex:indexPath.row];

    cell.textLabel.text = [newsItem objectForKey:@"title"];

    cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
    cell.textLabel.numberOfLines = 0;

    cell.detailTextLabel.text = [newsItem objectForKey:@"pubDate"];
    return cell;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *cellText = [news objectAtIndex:indexPath.row];
    UIFont *cellFont = [UIFont fontWithName:@"Helvetica-Bold" size:20.0f];
    CGSize constraintSize = CGSizeMake(320.0f, MAXFLOAT);

    CGSize labelSize = [cellText sizeWithFont:cellFont
                            constrainedToSize:constraintSize
                                lineBreakMode:UILineBreakModeWordWrap];

    return labelSize.height + 20.0f;
}
  • 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-06-17T08:38:54+00:00Added an answer on June 17, 2026 at 8:38 am

    It appears that your news array has dictionaries in it, not strings. So in tableView:heightForRowAtIndexPath: your NSString* cellText is actually a NSDictionary*.

    You just need to add an objectForKey: call after objectAtIndex: like so:

    NSString *cellText = [[news objectAtIndex:indexPath.row] objectForKey:@"title"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a novice programmer at best, but I am trying to play a
I'm a novice php programmer and having a problem assembling this code to work.
I'm a novice programmer using Visual C# 2010. I am trying to dynamically (during
I'm a novice programmer. This may be a simple problem but I've never seen
I'm a novice programmer and I'm trying to learn Android coding using Eclipse. This
I'm a novice programmer and I've run across a problem in creating a Console
A noob question here, by a novice programmer. I am trying to do a
I'm a novice programmer and I am trying to write Sudoku Generator. I know
(I'm a complete novice programmer) I recently came across a problem with my custom
Forgive me if this is a silly question but I am a novice programmer,

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.