Alex Rivera | Logout

UITableView scrolling crashes App

Asked 2009-06-14T09:21:09.510
11

Preface: I am new to the iPhone SDK, Obj-C, Interface Builder and Cocoa. I'm likely doing something obviously wrong.

Question: I have a UITableView which crashes if I scroll it. It will scroll a little to reveal the full cell of the bottom most half-hidden cell, but won't load the next one. Similarly, if I scroll past the top to fully hide the bottom most cell, and it rubber bands back to show that cell, it will crash before showing it. This strikes me as odd because it is drawing the first 7 of 11 cells correctly. The cell data is in an NSArray, in a UITableViewController linked as both the dataSource and delegate for the UITableView in Interface Builder. It works when the view initializes.

I'm making an App I thought I'd be done with 2 days ago that just calculates combinations and displays a list of them in what I thought would be a convenient scrolling table view. Right now, it doesn't even calculate everything, the NSArray in the DataSource is initialized once with some strings like @"Hello" and @"World".

Steps to reproduce: Because I'm using IB, I can't exactly show you the full story in code. So I'm going to describe what I did so far and hope it doesn't make you sleepy.

Made a new "Tab Bar Application" in Xcode, because I want 2 tabs, and I don't want a nav bar nor a full screen table. I moved the MainWindow.xib's first tab view out into FirstView.xib as an analogue to the given SecondView.xib. This worked nicely. I modified the view to contain two UITextFields for inputs, and a UITableView for output. This worked but the table was empty. I subclassed the UITableViewController wherein I populated an NSArray property named combinations with

Edit
Report

1 Answer

2

I had the same issue and fixed it by adding nil into an array as the last item.

It was crashing for this:

pairs = [[NSArray alloc] initWithObjects:@"EUR/USD",@"USD/JPY",@"GBP/USD",@"USD/CHF",@"USD/CAD"];

but not for this:

pairs = [[NSArray alloc] initWithObjects:@"EUR/USD",@"USD/JPY",@"GBP/USD",@"USD/CHF",@"USD/CAD",nil];

Hope this helps.

answered 2011-07-14T22:07:19.237

Your Answer