gpt4 book ai didi

iphone - 迭代 UITextView 的 NSMutableArray 导致应用程序崩溃

转载 作者:行者123 更新时间:2023-11-28 23:00:14 27 4
gpt4 key购买 nike

我想迭代 Uitextview NsmutableArray 但程序崩溃并给出以下错误,

"""-[__NSCFString text]: unrecognized selector sent to instance 0x861c2f0"""

请检查这段代码,并给出一些可能的解决方案...

谢谢你...

for ( x = 0; x < TextViewArray.count; x++) 
{
// here TextViewArray is a NSMutableArray
UITextView *textField1 = [TextViewArray objectAtIndex:x];
float diff3;
diff3 = [textField1.text floatValue]; // The program crashes in this line ,"""""" -[__NSCFString text]: unrecognized selector sent to instance 0x861c2f0""""" , here I am checking for a float value but i want to use string value instead of float value in this line how to do this?

NSLog(@"diff3 is %f",diff3);
textField1.text = [[NSString alloc] initWithFormat:@"%.2f",diff3];
TXT_First_Tag = [TextViewArray objectAtIndex:x]; // here uitextview *TXT_First_Tag;
NSLog(@"txt3 is %d",x);

TXT_First_Tag.tag = x;
NSLog(@" p is %d", x);

//textField1.text = [[NSString alloc] initWithFormat:@"%.2f",diff2];

//NSLog(@"Diff is %f",diff2);
}

最佳答案

您的数组在给定索引处包含一个字符串,因此出现错误“""-[__NSCFString text]:无法识别的选择器发送到实例 0x861c2f0"""。检查数组是否只包含 UITextViews

关于iphone - 迭代 UITextView 的 NSMutableArray 导致应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10136638/

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