在Objective-C中保护@protected [英] @protected in Objective-C

查看:170
本文介绍了在Objective-C中保护@protected的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的类:

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

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

还有一个:

#import <UIKit/UIKit.h>

@interface MyChildTableViewController : MyTableViewController
{
}

- (void)someMethod;

问题是我无法使用 _fetchedResultsController MyChildTableViewController 类中。我得到编译时错误:'_fetchedResultsController'未声明(首次在此函数中使用)`

The problem is that I can't use _fetchedResultsController in MyChildTableViewController class. I get compile-time error: '_fetchedResultsController' undeclared (first use in this function)`

这里有什么问题?

推荐答案

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

ughoavgfhw posted right answer in comments. I've asked him (in comments, also) to rewrite it as an answer - so I can accept it. But he didn't. So I will post my own answer, simply to close the question and remove it from unanswered.

解决方案:

更改 C / C ++编译器版本到项目设置中的 LLVM编译器2.0

The solution:
Change C/C++ Compiler Version to LLVM compiler 2.0 in your project's settings.

这篇关于在Objective-C中保护@protected的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆