i'm receiving the following errors, very new to iphone dev and objective C. I am very much willing to send over my project for someone to have a look, i'm running in circles and have no idea what to do next!
2010-11-10 19:38:07.822 iShisha[2698:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** Call stack at first throw:
(
0 CoreFoundation 0x025f9b99 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0274940e objc_exception_throw + 47
2 CoreFoundation 0x025ef695 -[__NSArrayM objectAtIndex:] + 261
3 iShisha 0x00003dc5 -[MapViewController tableView:cellForRowAtIndexPath:] + 1262
4 UIKit 0x0032dd6f -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 619
5 UIKit 0x00323e02 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
6 UIKit 0x00338774 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
7 UIKit 0x003307ec -[UITableView layoutSubviews] + 242
8 QuartzCore 0x046d7481 -[CALayer layoutSublayers] + 177
9 QuartzCore 0x046d71b1 CALayerLayoutIfNeeded + 220
10 QuartzCore 0x046d02e0 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 302
11 QuartzCore 0x046d0040 _ZN2CA11Transaction6commitEv + 292
12 QuartzCore 0x04700ebb _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
13 CoreFoundation 0x025daf4b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
14 CoreFoundation 0x0256fb27 __CFRunLoopDoObservers + 295
15 CoreFoundation 0x02538ce7 __CFRunLoopRun + 1575
16 CoreFoundation 0x02538350 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x02538271 CFRunLoopRunInMode + 97
18 GraphicsServices 0x02ed800c GSEventRunModal + 217
19 GraphicsServices 0x02ed80d1 GSEventRun + 115
20 UIKit 0x002caaf2 UIApplicationMain + 1160
21 iShisha 0x00001de8 main + 102
22 iShisha 0x00001d79 start + 53
)
terminate called after throwing an instance of 'NSException'
[Session started at 2010-11-10 19:38:15 +0000.]
Pending breakpoint 1 - ""MapViewController.m":204" resolved
Pending breakpoint 2 - ""MapViewController.m":317" resolved
Pending breakpoint 3 - "objc_exception_throw" resolved
(gdb)
I don't think there is a need to change from static to dynamic cells for this one (there are cases where you may need the cells to be static). What may have caused this problem is that you may have only named 0 sections for your table view in the "Attributes Inspector" section in the storyboard. All you need to do is increase this number to 1 or as many sections as you may need.
Well I think that's what @styfle's problem was.
In CocoaTouch, tables have a delegate and a data source. The delegate sends and receives messages for the table view, and the data source controls the information that goes in the table and the table's headers and footers. The data source tells the table how many rows to draw, how many sections, what to put as the section titles, etcetera.
The table view queries the data source for how many rows to draw via the
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
method. Then, in the
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
method, the tableView asks for a cell to populate the table from the data source. When programming for the iPhone, tables are mostly populated by an array, a single variable (object) that contains many other variables (objects). You tell an array what object you want, by asking
object = [array objectAtIndex:INTEGER]; //where INTEGER is an unsigned (zero or greater, no minus)
what happened, is that your data source is expecting X number of objects for the table, and there are X-Y available. If it thinks there are 10, but there are only 9, when the table asks for the 10th object, you get a crash because there is no object to give.
look in your code for hte line
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
and see what that code is. Chances are you're providing the wrong data there.
Good luck
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With