gpt4 book ai didi

iOS:在 ViewController 类型的对象上找不到属性

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:07:30 24 4
gpt4 key购买 nike

所以我试图将一个浮点值设置到另一个 View Controller NewLinkViewController 中。

这是我的代码:

    - (IBAction)selectSize:(id)sender {
UIButton *selectSize = (UIButton *) sender;
sizeChosen = [[[selectSize titleLabel] text] floatValue];
[self dismissViewControllerAnimated:YES completion:^{
[mainController setMySizeLabel:sizeChosen];
[NewLinkViewController.sizeChosen = sizeChosen];

}];

我收到此错误:http://puu.sh/7WSA9.png (说“在类型为‘NewLinkViewController’的对象上找不到属性‘sizeChosen’”)

我的 NewLinkViewController.h 中显然有 @property,如下所示:

    @property float sizeChosen;

我做错了什么?

最佳答案

看起来您是在类而不是类的对象上设置属性 [NewLinkViewController.sizeChosen = sizeChosen];

此外,如果您使用点语法,则不需要方括号。

关于iOS:在 ViewController 类型的对象上找不到属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22882345/

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