简体   繁体   English

没有加载Objective-C类 - 如何调试它

[英]Objective-C category is not loaded - How to debug this

I have two projects which the RestKit framework . 我有两个RestKit框架项目。

One project works without problems but another project fails, as soon as the RestKit framework is used. 一旦使用RestKit框架,一个项目没有问题,但另一个项目失败。

I found out that the failing code is this: 我发现失败的代码是这样的:

return [anNSString MD5];

The MD5 method is a category method and is imported like this: MD5方法是一种类别方法,导入方式如下:

#import "NSString+MD5.h"

However, in one project, I keep getting the following error: 但是,在一个项目中,我不断收到以下错误:

-[__NSCFString MD5]: unrecognized selector sent to instance 0x88a3390

I understand the basics of categories, and that they can be loaded at runtime, but I don't see why the category does not get loaded in this case. 我理解类别的基础知识,并且可以在运行时加载它们,但我不明白为什么在这种情况下不会加载类别。

These are the files on github: NSString+MD5.m , NSString+MD5.h , 这些是github上的文件: NSString + MD5.mNSString + MD5.h

Make sure you have the -ObjC flag enabled. 确保启用了-ObjC标志。 Or it will not link categories in a static library. 或者它不会链接静态库中的类别。

Objective-C categories in static library 静态库中的Objective-C类别

It's not enough to just include the header file. 仅包含头文件是不够的。 You also need to compile and link the .m file in your project. 您还需要编译和链接项目中的.m文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM