Iphone 从阵列崩溃模拟器设置UITableViewCell
我已经尝试了很多事情来实现这一目标,但我完全失败了 我得到以下错误Iphone 从阵列崩溃模拟器设置UITableViewCell,iphone,xcode,uitableview,Iphone,Xcode,Uitableview,我已经尝试了很多事情来实现这一目标,但我完全失败了 我得到以下错误 -[\uu NSArrayM isEqualToString:]:发送到实例0x4d41210的选择器无法识别 2011-01-31 17:03:49.496 I故障[11954:207]***由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[\uu NSArrayM isEqualToString::]:未识别的选择器发送到实例0x4d41210 我的代码如下所示 // Cus
-[\uu NSArrayM isEqualToString:]:发送到实例0x4d41210的选择器无法识别
2011-01-31 17:03:49.496 I故障[11954:207]***由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[\uu NSArrayM isEqualToString::]:未识别的选择器发送到实例0x4d41210
我的代码如下所示
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"FIRST LINE ROW");
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Set up the cell...
hold = [self.names objectAtIndex:[indexPath row]];
//NSString *hold = [big objectAtIndex:indexPath.row];
//NSLog(@"%@",hold);
//hold = @"TEST TEST";
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:15];
cell.textLabel.text = hold;
return cell;
}
如果我取消注释hold=@“test test”
表将正确填充“test test”
抱歉,代码太多了,但我想如果我展示的更多,我可能会得到更多的帮助
我不知道是什么导致了这个错误。我的Json解析是正确的,我的名称数组在我想将其显示到完全分离的表时正确填充
2011-02-01 10:11:40.606 IHaulage[15827:207] -[__NSArrayM isEqualToString:]: unrecognized selector sent to instance 0x9b29560
2011-02-01 10:11:40.607 IHaulage[15827:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM isEqualToString:]: unrecognized selector sent to instance 0x9b29560'
*** Call stack at first throw:
(
0 CoreFoundation 0x00db9be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f0e5c2 objc_exception_throw + 47
2 CoreFoundation 0x00dbb6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d2b366 ___forwarding___ + 966
4 CoreFoundation 0x00d2af22 _CF_forwarding_prep_0 + 50
5 UIKit 0x003e1340 -[UILabel setText:] + 72
6 IHaulage 0x0000746e -[ManageContractors tableView:cellForRowAtIndexPath:] + 434
7 UIKit 0x003367fa -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634
8 UIKit 0x0032c77f -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
9 UIKit 0x00341450 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
10 UIKit 0x00339538 -[UITableView layoutSubviews] + 242
11 QuartzCore 0x01c77451 -[CALayer layoutSublayers] + 181
12 QuartzCore 0x01c7717c CALayerLayoutIfNeeded + 220
13 QuartzCore 0x01c7037c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
14 QuartzCore 0x01c700d0 _ZN2CA11Transaction6commitEv + 292
15 QuartzCore 0x01ca07d5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
16 CoreFoundation 0x00d9afbb __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
17 CoreFoundation 0x00d300e7 __CFRunLoopDoObservers + 295
18 CoreFoundation 0x00cf8bd7 __CFRunLoopRun + 1575
19 CoreFoundation 0x00cf8240 CFRunLoopRunSpecific + 208
20 CoreFoundation 0x00cf8161 CFRunLoopRunInMode + 97
21 GraphicsServices 0x016ee268 GSEventRunModal + 217
22 GraphicsServices 0x016ee32d GSEventRun + 115
23 UIKit 0x002d142e UIApplicationMain + 1160
24 IHaulage 0x00001ad8 main + 102
25 IHaulage 0x00001a69 start + 53
26 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
愚蠢的是我在使用断点调试时所做的堆栈跟踪日志
#0 -[ManageContractors tableView:cellForRowAtIndexPath:] (self=0x4b56490, _cmd=0x6dfd5f, tableView=0x5048c00, indexPath=0x8d163f0) at /Users/mdedys/Dropbox/iHaulage Code/iPhone/IHaulage/Classes/ManageContractors.m:49
#1 0x003367fa in -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] ()
#2 0x0032c77f in -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] ()
#3 0x00341450 in -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] ()
#4 0x00339538 in -[UITableView layoutSubviews] ()
#5 0x01c77451 in -[CALayer layoutSublayers] ()
#6 0x01c7717c in CALayerLayoutIfNeeded ()
#7 0x01c7037c in CA::Context::commit_transaction ()
#8 0x01c700d0 in CA::Transaction::commit ()
#9 0x01ca07d5 in CA::Transaction::observer_callback ()
#10 0x00d9afbb in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#11 0x00d300e7 in __CFRunLoopDoObservers ()
#12 0x00cf8bd7 in __CFRunLoopRun ()
#13 0x00cf8240 in CFRunLoopRunSpecific ()
#14 0x00cf8161 in CFRunLoopRunInMode ()
#15 0x016ee268 in GSEventRunModal ()
#16 0x016ee32d in GSEventRun ()
#17 0x002d142e in UIApplicationMain ()
#18 0x00001ad8 in main (argc=1, argv=0xbfffeff0) at /Users/mdedys/Dropbox/ihaulage code/iPhone/IHaulage/main.m:14
问题是nss指出我的数据不是字符串。当我把它展示在桌子上时,我不得不投下它
cell.textLabel.text = [[self.names objectAtIndex:indexPath.row]description]
关键字是description这将其强制转换为字符串问题在于,无论您在哪里拥有isEqualToString:您都在对数组而不是字符串调用此方法。把代码贴在那里。我哪里都没有。我不在任何地方使用isEqualToString..你有完整的堆栈跟踪吗?那会有很大帮助。另外,您是否确认
NSLog(@“%@,[status objectForKey:@“Name]”)当代码>点击此行cell.textlab.text=hold时,它确实正在打印NSStrings
;我在我的原始问题中发布了错误日志我很确定这是一个字符串,有没有办法测试它是否确实是一个字符串?当我不填充表格,但单击某一行时会显示一条警告消息,并在我的字符串显示为(“测试”)时显示hold对象,这是否会导致表格显示出现问题?
#0 -[ManageContractors tableView:cellForRowAtIndexPath:] (self=0x4b56490, _cmd=0x6dfd5f, tableView=0x5048c00, indexPath=0x8d163f0) at /Users/mdedys/Dropbox/iHaulage Code/iPhone/IHaulage/Classes/ManageContractors.m:49
#1 0x003367fa in -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] ()
#2 0x0032c77f in -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] ()
#3 0x00341450 in -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] ()
#4 0x00339538 in -[UITableView layoutSubviews] ()
#5 0x01c77451 in -[CALayer layoutSublayers] ()
#6 0x01c7717c in CALayerLayoutIfNeeded ()
#7 0x01c7037c in CA::Context::commit_transaction ()
#8 0x01c700d0 in CA::Transaction::commit ()
#9 0x01ca07d5 in CA::Transaction::observer_callback ()
#10 0x00d9afbb in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#11 0x00d300e7 in __CFRunLoopDoObservers ()
#12 0x00cf8bd7 in __CFRunLoopRun ()
#13 0x00cf8240 in CFRunLoopRunSpecific ()
#14 0x00cf8161 in CFRunLoopRunInMode ()
#15 0x016ee268 in GSEventRunModal ()
#16 0x016ee32d in GSEventRun ()
#17 0x002d142e in UIApplicationMain ()
#18 0x00001ad8 in main (argc=1, argv=0xbfffeff0) at /Users/mdedys/Dropbox/ihaulage code/iPhone/IHaulage/main.m:14
cell.textLabel.text = [[self.names objectAtIndex:indexPath.row]description]