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

  • Home
  • SEARCH
  • 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 490509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:54:59+00:00 2026-05-13T01:54:59+00:00

In my UIView nib file, I’ve got a UITableView which takes up about half

  • 0

In my UIView nib file, I’ve got a UITableView which takes up about half the screen. The correpsponding .h and .m files are:

// helloViewController.h
#import <UIKit/UIKit.h>
@interface helloViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
    NSArray *locationArray;
}
@property (nonatomic, retain) NSArray *locationArray;
@end

// helloViewController.m
@synthesize locationArray;
- (void)viewDidLoad {
    locationArray = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8",  @"9",  @"10",  @"11", nil];
    [super viewDidLoad];
}


- (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];
    }
    [[cell textLabel] setText: [locationArray objectAtIndex:[indexPath row]]];

    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 8;
}

When I run this it crashes when I try to scroll the table (with no error in the debugger). However, if I replace [[cell textLabel] setText: [locationArray objectAtIndex:[indexPath row]]]; with

[[cell textLabel] setText:@"Boom"];

… it does not crash….

What is causing this problem? The delegate and datasource are connected to the File’s Owner in IB, and the File’s Owner’s class is set to the correct class. Is it an issue that I’m using a table view within a uiview in the nib?

  • 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-13T01:54:59+00:00Added an answer on May 13, 2026 at 1:54 am

    The problem is that you’re setting locationArray to an autoreleased object in viewDidLoad. Then you try to access this object again where you want to set the cell, but the array has been deallocated by then.

    You should use the retain-property you defined (you’re setting the array directly, not using the property) and read some more on memory management. 😉

    self.locationArray = [NSArray arrayWith...];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a NIB file with a UIView, a couple of UIImageView's (including a
I am using a UITableViewController which uploads a table. I have a Nib File
I have a UIView that will eventually contain about 2 screens worth of information.
I have a UIView with a UITableView for a subview. The UIView has an
I know it is easy to create a NIB file easily with interface builder
I've double checked all the connections in the nib file. My code - //
.Hi, I have a nib file that contains an header that will be used
I've noticed that there are two different ways to load nib/xib files: via the
Do Nib files automatically initialize certain properties? In most objective-c code I've seen, you
If I have a UIView (or UIView subclass) that is visible, how can I

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.