错误:“类别”在XCode 4中声明为不同类型的符号 [英] Error : "Category" declared as different kind of symbol in XCode 4

查看:103
本文介绍了错误:“类别”在XCode 4中声明为不同类型的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了自己的类Category.h和Category.m。 Category类继承NSObject。在我的项目中,只有一个名为Category的类。

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!

推荐答案

如果您查看文档的类别类型是:

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

typedef struct objc_category *Category;

您收到此错误,因为类别是定义为指向 struct objc_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:


  • 您的昵称:iAsh

  • ClassPrefix:IA

  • 示例类:IACategory

或来自项目名称:


  • 项目:很棒的项目;

  • 类前缀:AP

  • 示例类:APCategory

另外,使用文档进行复核总是很好。你很难打到现有的课程,但可能。

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

这篇关于错误:“类别”在XCode 4中声明为不同类型的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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