gpt4 book ai didi

ios - 由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序,原因 : '-[Home isEqualToString:]

转载 作者:行者123 更新时间:2023-11-28 22:35:30 28 4
gpt4 key购买 nike

我正在从网络服务中获取数据:

//temp1 is NSDictionary
//responseArr1 is NSMutableArray
for(temp1 in responseArr1).......,
{
quesTxt = [[temp1 objectForKey:@"question_text"] stringByReplacingOccurrencesOfString:@"%PROFILENAME%" withString:del.onlyFirstName];

quesID = [temp1 objectForKey:@"idlife_stage_question"];

Home *objHome=[[Home alloc] init];

objHome.homeQuesTxt = quesTxt;
objHome.homeQuesID = quesID;

[quesArray addObject:objHome];

//[quesArray addObject:[[temp1 objectForKey:@"question_text"] stringByReplacingOccurrencesOfString:@"%PROFILENAME%" withString:del.onlyFirstName]];//this works fine

}

当我尝试在选择器 View 中填充所有日期时,它给出了异常。

选择器 View 委托(delegate):

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
UILabel *retval = (id)view;
if (!retval) {
retval= [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [pickerView rowSizeForComponent:component].width, [pickerView rowSizeForComponent:component].height)];
}

retval.text = [quesArray objectAtIndex:row];.........// **EXCEPTION HERE**...

retval.font = [UIFont boldSystemFontOfSize:14];
retval.numberOfLines = 3;

return retval;
}

我的网络服务示例:

{
"idlife_stage_question" = 35;
"life_stage_idlife_stage" = 1;
"profile_idprofile" = 0;
"question_text" = "When %PROFILENAME% first smiled?";..//%PROFILENAME% replaces with user name which i have
sequence = 34;
}

Home 是 NSObject 的子类

请帮忙。

最佳答案

retval.text = [quesArray objectAtIndex:row];

在这里您正在访问 quesArray

如:[quesArray addObject:objHome];

objHome 是:Home *objHome=[[Home alloc] init];

所以您的错误就在这里,您试图将对象放入需要 NSStringretval 中。

你需要使用一些东西作为:

retval.text = [[quesArray objectAtIndex:row] homeQuesTxt]; //or anyother property that you want to show in text

关于ios - 由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序,原因 : '-[Home isEqualToString:],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16167442/

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