@protected in Objective-C

£可爱£侵袭症+ 提交于 2019-12-04 23:40:55

问题


I have a simple class:

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

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

And one more:

#import <UIKit/UIKit.h>

@interface MyChildTableViewController : MyTableViewController
{
}

- (void)someMethod;

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

What's wrong here?


回答1:


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.

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




回答2:


I also had the same problem, by using self->, everything worked fine.



来源:https://stackoverflow.com/questions/6659383/protected-in-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!