亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

就是在ViewCtrlB中 NSlog 能打印出 todayData,但賦值到setText會有異常

就是在ViewCtrlB中 NSlog 能打印出 todayData,但賦值到setText會有異常

iOS
白豬掌柜的 2023-04-16 23:19:37
ValueObject#import <Foundation/Foundation.h>@interface CurrentDataVO : NSObject@property (nonatomic, retain) NSString *crt;@property (nonatomic, retain) NSString *last;@property (nonatomic, retain) NSString *dataType;@property (nonatomic, retain) NSString *date;@property (nonatomic, retain) NSMutableArray *days;@property (nonatomic, retain) NSString *cv; - (void)showAllData;#import "CurrentDataVO.h"@implementation CurrentDataVO@synthesize crt;@synthesize last;@synthesize dataType;@synthesize date;@synthesize days;@synthesize cv; - (id)init {    self = [super init];    if (self) {         days = [[NSMutableArray alloc] init];     }    return self; } - (void)showAllData {    NSLog(@"%@", crt);    NSLog(@"%@", last);    NSLog(@"%@", dataType);    NSLog(@"%@", date);    NSLog(@"%@", cv);    NSLog(@"%@", days); }@endViewCtrlA[cell setContentData:todayData withYesData:vo.last];ViewCtrlB- (void)setContentData:(NSString *)todayData withYesData:(NSString *)yesData {    [todayDataLabel setText:todayData];    [yesDataLabel setText:yesData]; }cell不為nil在ViewCtrlB中 NSlog 能打印出 todayData,但是賦值到setText中時會拋出異常。2012-12-13 14:10:35.510 mbaforios[29723:fb03] 10052012-12-13 14:10:35.511 mbaforios[29723:fb03] -[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x6b904e02012-12-13 14:10:35.511 mbaforios[29723:fb03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x6b904e0'*** First throw call stack: (0x12f1022 0x17a2cd6 0x12f2cbd 0x1257ed0 0x1257cb2 0x46a0ff 0x7abd 0x440c 0x93d9 0xd2da49 0xd2be84 0xd2cea7 0xd2be3f 0xd2bfc5 0xc70f5a 0x1a52a39 0x1b1f596 0x1b1f861 0x1a49120 0x1b1f117 0x1a48fbf 0x12c594f 0x1228b43 0x1228424 0x1227d84 0x1227c9b 0x1fab7d8 0x1fab88a 0x32a626 0x2ad2 0x2a45) terminate called throwing an exception(lldb)
查看完整描述

2 回答

?
30秒到達戰場

TA貢獻1828條經驗 獲得超6個贊

我猜是你服務端過來的時候把NSNumber對象認為了NSString對象,然后你打印NSNumber是對的,但是給Label賦值的時候就報錯了,因為它不是NSString而是NSNumber,跟copy不copy,釋放不是釋放沒有關系。只是類型錯了。

查看完整回答
反對 回復 2023-04-20
?
胡說叔叔

TA貢獻1804條經驗 獲得超8個贊

NSString 是不是這樣的 @property (nonatomic, assign) 改為@property (nonatomic, strong)

查看完整回答
反對 回復 2023-04-20
  • 2 回答
  • 0 關注
  • 184 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號