gpt4 book ai didi

ios - -[用户长度] : unrecognized selector sent to instance 0x7fc7b60143e0'

转载 作者:行者123 更新时间:2023-11-29 02:28:23 24 4
gpt4 key购买 nike

我有以下代码并收到标题中指示的错误代码:这是我发送给用户对象的唯一消息(除了使用“new”初始化它)当我发表评论时 addObject: 它不会提示。有人可以帮忙吗?谢谢!

self.freshUser.name = self.name.text;
self.freshUser.age = (int)self.age.text;
self.freshUser.gender = self.gender.text;

//NSLog(@"%@",[NSThread callStackSymbols]);
[appDelegate.users addObject:self.freshUser];

(我的用户对象是 NSObject 的子类。它有更多我不使用的属性。只是一些额外的信息)

-(UITableViewCell *)tableView:(UITableView *)tableViewPara cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UserCell *cell = [tableViewPara dequeueReusableCellWithIdentifier:usersTableIdentifier forIndexPath:indexPath];

if(indexPath.row == [appDelegate.users count]){
cell.nameLabel.text = @"+";
cell.nameLabel.font = [UIFont systemFontOfSize:36];
cell.bgImg.image = [UIImage imageNamed:@"background_gray"];
cell.statusImg.image = nil;
}else{
cell.nameLabel.text = appDelegate.users[indexPath.row];
cell.nameLabel.font = [UIFont systemFontOfSize:17];
cell.bgImg.image = [UIImage imageNamed:@"background_dark_red"];
cell.statusImg.image = [UIImage imageNamed:@"icon_cloud"];
}
cell.nameLabel.textAlignment = NSTextAlignmentCenter;
cell.nameLabel.textColor = [UIColor whiteColor];
cell.nameLabel.backgroundColor = [UIColor clearColor];

return cell;
}

空间

0   CoreFoundation                      0x000000010ff1bf35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010fbb4bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010ff2304d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010fe7b27c ___forwarding___ + 988
4 CoreFoundation 0x000000010fe7ae18 _CF_forwarding_prep_0 + 120
5 UIKit 0x00000001104d034b -[UILabel _setFont:] + 101
6 Raymio 0x000000010f67857f -[StartViewController tableView:cellForRowAtIndexPath:] + 991
7 UIKit 0x00000001103ff4b3 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 508
8 UIKit 0x00000001103defb1 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2846
9 UIKit 0x00000001103f4e3c -[UITableView layoutSubviews] + 213
10 UIKit 0x0000000110381973 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
11 QuartzCore 0x0000000113c09de8 -[CALayer layoutSublayers] + 150
12 QuartzCore 0x0000000113bfea0e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
13 QuartzCore 0x0000000113bfe87e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
14 QuartzCore 0x0000000113b6c63e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
15 QuartzCore 0x0000000113b6d74a _ZN2CA11Transaction6commitEv + 390
16 QuartzCore 0x0000000113b6ddb5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
17 CoreFoundation 0x000000010fe50dc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
18 CoreFoundation 0x000000010fe50d20 __CFRunLoopDoObservers + 368
19 CoreFoundation 0x000000010fe46b53 __CFRunLoopRun + 1123
20 CoreFoundation 0x000000010fe46486 CFRunLoopRunSpecific + 470
21 GraphicsServices 0x00000001134fd9f0 GSEventRunModal + 161
22 UIKit 0x0000000110308420 UIApplicationMain + 1282
23 Raymio 0x000000010f678a83 main + 115
24 libdyld.dylib 0x00000001124ab145 start + 1

最佳答案

这一行:

cell.nameLabel.text = appDelegate.users[indexPath.row];

您正在尝试将 User 对象设置为标签字段的文本。那是行不通的。你会想要这个或类似的东西:

cell.nameLabel.text = ((User *)appDelegate.users[indexPath.row]).name;

关于ios - -[用户长度] : unrecognized selector sent to instance 0x7fc7b60143e0',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27209292/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com