实例变量在子类中不可用..?

发布于 2024-10-16 00:19:47 字数 324 浏览 3 评论 0原文

我尝试过删除缓存、清理所有目标等。 根据我的配色方案,我的超类中的实例变量会突出显示为绿色,但编译器随后会失败,并提示“

"score" (or whatever) undeclared"

如果我在一个方法中有两个引用,则只有第一个引用失败”。如果我忽略它们,或者使用子类标头中的实例变量,则应用程序可以正常编译并运行。

就在两天前,它还可以正常工作。我想知道我是否不小心点击了打开某些奇怪设置的快捷方式?

如果这很重要的话,它正在 3.2 iPad 模拟器中运行。

这是一个奇怪的......希望有人以前遇到过这个。

I've tried removing cache, clean all targets, etc.
Instance variables from my super class are getting highlighted green according to my color scheme, but the compiler then fails saying

"score" (or whatever) undeclared"

If I have two references in one method, only the first one fails. If I leave them out, or use instance variables from my subclasses header, the app compiles and runs fine.

It was working literally just 2 days ago. I wonder if I accidentally hit a shortcut that turned on some weird setting?

It's running in the 3.2 iPad simulator, if that matters.

It's a weird one.. hope someone has run into this before.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只是我以为 2024-10-23 00:19:47

听起来你的实例变量被声明为@private。这意味着只有那个确切的类才能访问它们。如果你想让子类访问ivars,直接将@protected放在它们上面,例如

@protected
id myiVar;
NSString *myStringIVar;

Sounds like your instance variables are declared as @private. This means that only that exact class can access them. If you want subclasses to access the ivars directly put @protected above them, eg

@protected
id myiVar;
NSString *myStringIVar;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文