在 iOS 中调用 Google Toolbox for Mac NSString 类别方法时无法识别选择器

发布于 2024-10-16 22:49:54 字数 1619 浏览 5 评论 0原文

我正在构建一个用于 iOS 项目的静态库,并且我想解码从 Web 服务返回的 XML 实体。我已获取 Google Toolbox for Mac 并将以下文件添加到我的项目:

  • GTMDefines.h
  • GTMNSString+HTML.h
  • GTMNSString+HTML.m

然后在我自己的 .m 文件中我这样做:

#import "GTMNSString+HTML.h"

// then in one of my methods:
NSString *value = [anotherNSStringValue gtm_stringByUnescapingFromHTML];

代码编译正常,但是当我运行使用我的静态库的应用程序时,它会崩溃并显示 < code>NSInvalidArgumentException,抱怨 gtm_stringByUnescapingFromHTML 选择器无法识别 NSString

2011-02-10 12:21:38.401 MyApp[20356:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString gtm_stringByUnescapingFromHTML]: unrecognized selector sent to instance 0x71403e0'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x0111bbe9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x012705c2 objc_exception_throw + 47
    2   CoreFoundation                      0x0111d6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x0108d366 ___forwarding___ + 966
    4   CoreFoundation                      0x0108cf22 _CF_forwarding_prep_0 + 50
    5   MyApp                               0x00028dcf -[GSMyAppXMLParser parseData:] + 714
    // Rest of stack trace removed
)
terminate called after throwing an instance of 'NSException'

我在 Stack Overflow 上发现了一些类似的问题,并且在每种情况下提问者随后评论说他们通过调整链接器设置来修复它 - 但没有透露哪个设置!如果有人能帮助我,我将永远感激不已!

I'm building a static library for use in an iOS project, and I want to decode XML entities returned from a web service. I've grabbed Google Toolbox for Mac and added the following files to my project:

  • GTMDefines.h
  • GTMNSString+HTML.h
  • GTMNSString+HTML.m

Then in my own .m file I'm doing this:

#import "GTMNSString+HTML.h"

// then in one of my methods:
NSString *value = [anotherNSStringValue gtm_stringByUnescapingFromHTML];

The code compiles fine, but when I run the app that uses my static library it crashes with a NSInvalidArgumentException, complaining that the gtm_stringByUnescapingFromHTML selector isn't recognised for NSString:

2011-02-10 12:21:38.401 MyApp[20356:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString gtm_stringByUnescapingFromHTML]: unrecognized selector sent to instance 0x71403e0'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x0111bbe9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x012705c2 objc_exception_throw + 47
    2   CoreFoundation                      0x0111d6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x0108d366 ___forwarding___ + 966
    4   CoreFoundation                      0x0108cf22 _CF_forwarding_prep_0 + 50
    5   MyApp                               0x00028dcf -[GSMyAppXMLParser parseData:] + 714
    // Rest of stack trace removed
)
terminate called after throwing an instance of 'NSException'

I've found a few similar issues on Stack Overflow, and in each case the questioner has subsequently commented that they fixed it by tweaking a linker setting - but without disclosing which setting! If anyone can help me with this I'd be forever grateful!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难理解 2024-10-23 22:49:54

我猜这将是 -ObjC-all_load 标志。

您将这些添加到链接到库的应用的“其他链接器标志”,而不是库本身。

有关详细信息,请参阅:http://developer.apple.com/library/mac/#qa /qa2006/qa1490.html

I’m guessing that would be the -ObjC and -all_load flags.

You add these to the ‘Other Linker Flags’ of the app that links agains the library, not the library itself.

For more info see: http://developer.apple.com/library/mac/#qa/qa2006/qa1490.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文