Error : “Category” declared as different kind of symbol in XCode 4 [closed]

拥有回忆 提交于 2020-01-10 20:25:13

问题


I have created my own classes Category.h and Category.m. Category class is inheriting NSObject. In my project there is only one class named Category.

At following line, it's showing me this error.

@interface Category : NSObject

Any help would be greatly appreciated. Thanks!


回答1:


If you check the documentation there's Category type which is:

typedef struct objc_category *Category;

You are getting this error because Category is defined as a pointer to struct objc_category.

If you want to avoid these kind of errors I suggest you adding your own prefix to all the classes you make in the project. Either from your name:

  • Your nickname: iAsh
  • ClassPrefix: IA
  • Example class: IACategory

or from project name:

  • Project: Awesome Project;
  • Class prefix: AP
  • Example class: APCategory

Also double-checking with documentation is always good. It's very rare that you'll hit existing class, but possible.



来源:https://stackoverflow.com/questions/6814694/error-category-declared-as-different-kind-of-symbol-in-xcode-4

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