gpt4 book ai didi

iphone - 将 UITextField 标签转换为字符串

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

这给了我一个错误,“Bad Reciever type 'NSIntegar”(又名'int')。

    NSString *tempTag = [((UITextField *)[self.dataSetDictionary objectForKey:key]).tag stringValue];

试图将 uitextfield 的标签强制转换为字符串。我可以很好地使用 [NSString stringWithFormat],只是想不通为什么这种方式行不通。

最佳答案

你必须使用stringWithFormat:

UITextField *textField = (UITextField *)[self.dataSetDictionary objectForKey:key];
NSString *tempTag = [NSString stringWithFormat:@"%d", textField.tag];

just can't figure out why this way won't work.

因为 tag 是标量整数而不是对象。您不能向非对象发送像 stringValue 这样的消息。

关于iphone - 将 UITextField 标签转换为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8792053/

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