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 loaded an UIView out of a nib-file. I wrote some methods which I
I have a UIView and a UITableView in the same NIB file like so:
I have a NIB file with a UIView, a couple of UIImageView's (including a
I have created a UIView object using the contents of a NIB file like
I have a UITableView tableHeaderView defined in a nib file. The tableHeaderView contains a
I have a UIView control in the nib file that I am working on.
I have a UIView and I initialize it from a nib file. In my
how to I introduce use of a NIB file to my existing custom UIView?
I am loading a UIView from a NIB file with outlets and I want
I found similar question here: How to load a UIView using a nib file

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.