Hi,
This is a strange problem. Look at the code below:
Code:
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
if (self.rowTitles != nil)
cell.textLabel.text = [self.rowTitles count] > indexPath.row ? [self.rowTitles objectAtIndex:indexPath.row] : @"0";
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(170, 30, 500, 22)];
textField.keyboardType = UIKeyboardTypeNumberPad;
NSLog(@"The string at index is %@.", [self.values objectAtIndex:indexPath.row]);
if (self.values != nil)
textField.text = [self.values count] > indexPath.row ? [self.values objectAtIndex:indexPath.row] : @""; //Exception!!
cell.accessoryView = textField;
return cell;
The strangest thing is that the NSLog shows that there is a string at that index. However, when I set the textField's text (I tried using the setter without success), it causes the following exceptions:
Code:
2011-05-13 15:10:49.966 My App HD[1475:707] -[NSCFNumber _isNaturallyRTL]: unrecognized selector sent to instance 0x405e1d0
2011-05-13 15:10:49.983 My App HD[1475:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber _isNaturallyRTL]: unrecognized selector sent to instance 0x405e1d0'
*** Call stack at first throw:
(
0 CoreFoundation 0x3604064f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x35b99c5d objc_exception_throw + 24
2 CoreFoundation 0x360441bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3 CoreFoundation 0x36043649 ___forwarding___ + 508
4 CoreFoundation 0x35fba180 _CF_forwarding_prep_0 + 48
5 UIKit 0x367958a7 -[UITextField setText:] + 38
6 My Grapher HD 0x0002078f -[VSRawDataInputController tableView:cellForRowAtIndexPath:] + 590
7 UIKit 0x367d99ed -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 516
8 UIKit 0x367d976b -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 34
9 UIKit 0x367d20cd -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 936
10 UIKit 0x367d127d -[UITableView layoutSubviews] + 140
11 UIKit 0x3677d5fb -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 26
12 CoreFoundation 0x35fadf03 -[NSObject(NSObject) performSelector:withObject:] + 22
13 QuartzCore 0x317ccbb5 -[CALayer layoutSublayers] + 120
14 QuartzCore 0x317cc96d CALayerLayoutIfNeeded + 184
15 QuartzCore 0x317d21c5 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 212
16 QuartzCore 0x317d1fd7 _ZN2CA11Transaction6commitEv + 190
17 QuartzCore 0x317cb055 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 56
18 CoreFoundation 0x36017a35 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 16
19 CoreFoundation 0x36019465 __CFRunLoopDoObservers + 412
20 CoreFoundation 0x3601a75b __CFRunLoopRun + 854
21 CoreFoundation 0x35faaec3 CFRunLoopRunSpecific + 230
22 CoreFoundation 0x35faadcb CFRunLoopRunInMode + 58
23 GraphicsServices 0x312e441f GSEventRunModal + 114
24 GraphicsServices 0x312e44cb GSEventRun + 62
25 UIKit 0x367a6d69 -[UIApplication _run] + 404
26 UIKit 0x367a4807 UIApplicationMain + 670
27 My Grapher HD 0x00002abb main + 70
28 My Grapher HD 0x00002a70 start + 40
)
terminate called after throwing an instance of 'NSException'
The strings in the array were created with [NSString stringWithFormat:@"%g", number];
Please help if there's something I'm missing - thanks!