【问题标题】:@protected in Objective-CObjective-C 中的@protected
【发布时间】:2011-10-03 07:34:21
【问题描述】:

我有一个简单的课程:

#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>

@interface MyTableViewController : UITableViewController
{
@protected
    NSFetchedResultsController *_fetchedResultsController;
}

还有一个:

#import <UIKit/UIKit.h>

@interface MyChildTableViewController : MyTableViewController
{
}

- (void)someMethod;

问题是我不能在MyChildTableViewController 类中使用_fetchedResultsController。我得到编译时错误:'_fetchedResultsController' undeclared (first use in this function)`

这里有什么问题?

【问题讨论】:

  • P.S.:self-&gt;_fetchedResultsController 工作...
  • 如您所见,添加self-&gt; 有效。我还听说切换到 LLVM 可以让它在没有它的情况下工作,documentation 似乎表明它应该这样做。
  • ughoavgfhw,请写下您的评论作为答案 - 您的建议对我有帮助(我已将 C/C++ Compiler Version 更改为 LLVM compiler 2.0),我想将其标记为正确且关闭的问题。

标签: objective-c ios inheritance protected


【解决方案1】:

ughoavgfhw 在 cmets 中发布了正确答案。我已经要求他(也在 cmets 中)将其重写为答案 - 所以我可以接受它。但他没有。所以我会发布我自己的答案,只是为了关闭问题并将其从未回答中删除。

解决办法:
在项目设置中将 C/C++ Compiler Version 更改为 LLVM compiler 2.0

【讨论】:

    【解决方案2】:

    我也遇到了同样的问题,通过使用self->,一切正常。

    【讨论】:

      猜你喜欢
      • 2010-11-23
      • 2012-06-06
      • 2012-11-28
      • 2012-07-17
      • 2011-09-20
      • 2012-01-15
      • 2019-09-18
      • 2014-09-14
      • 2011-12-06
      相关资源
      最近更新 更多