• <tfoot id='fVI4w'></tfoot>

    <i id='fVI4w'><tr id='fVI4w'><dt id='fVI4w'><q id='fVI4w'><span id='fVI4w'><b id='fVI4w'><form id='fVI4w'><ins id='fVI4w'></ins><ul id='fVI4w'></ul><sub id='fVI4w'></sub></form><legend id='fVI4w'></legend><bdo id='fVI4w'><pre id='fVI4w'><center id='fVI4w'></center></pre></bdo></b><th id='fVI4w'></th></span></q></dt></tr></i><div id='fVI4w'><tfoot id='fVI4w'></tfoot><dl id='fVI4w'><fieldset id='fVI4w'></fieldset></dl></div>
  • <small id='fVI4w'></small><noframes id='fVI4w'>

        <bdo id='fVI4w'></bdo><ul id='fVI4w'></ul>
        <legend id='fVI4w'><style id='fVI4w'><dir id='fVI4w'><q id='fVI4w'></q></dir></style></legend>

        iOS 5:使 NSString 类别包括 NSCFConstantString?

        时间:2023-06-01

        <small id='MdWnN'></small><noframes id='MdWnN'>

          <i id='MdWnN'><tr id='MdWnN'><dt id='MdWnN'><q id='MdWnN'><span id='MdWnN'><b id='MdWnN'><form id='MdWnN'><ins id='MdWnN'></ins><ul id='MdWnN'></ul><sub id='MdWnN'></sub></form><legend id='MdWnN'></legend><bdo id='MdWnN'><pre id='MdWnN'><center id='MdWnN'></center></pre></bdo></b><th id='MdWnN'></th></span></q></dt></tr></i><div id='MdWnN'><tfoot id='MdWnN'></tfoot><dl id='MdWnN'><fieldset id='MdWnN'></fieldset></dl></div>

            <tbody id='MdWnN'></tbody>

            <legend id='MdWnN'><style id='MdWnN'><dir id='MdWnN'><q id='MdWnN'></q></dir></style></legend>

                <bdo id='MdWnN'></bdo><ul id='MdWnN'></ul>

                  <tfoot id='MdWnN'></tfoot>

                1. 本文介绍了iOS 5:使 NSString 类别包括 NSCFConstantString?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个 NSString 类别类 (NSString+URLEncoding.h).我遇到了未知的选择器崩溃,因为我调用类别方法的字符串已被 iOS 优化为 NSCFConstantString.

                  I have an NSString category class (NSString+URLEncoding.h). I am running into and unknown selector crash, because the string I am calling the category method has been optimized into an NSCFConstantString by iOS.

                  -[__NSCFConstantString URLEncodedString]: unrecognized selector sent to instance 0x290174
                  

                  我从以下方面了解到 iOS 5 中的 NSCFConstantStringNSCFString 优化:http://www.cocoanetics.com/2012/03/beware-of-nsstring-optimizations/

                  I learned of the NSCFConstantString vs. NSCFString optimizations in iOS 5 from: http://www.cocoanetics.com/2012/03/beware-of-nsstring-optimizations/

                  有谁知道我如何让 NSString 类别包含常量字符串,甚至强制 var 成为 NSString/NSCFString 而不是 NSCFConstantString?

                  Is anyone aware of how I can get the NSString category to include the Constant strings or even force the var to be an NSString/NSCFString and not an NSCFConstantString?

                  干杯,Z

                  -编辑-

                  • 链接器标志 -ObjC -all_load 都已实现
                  • NSString+URLEncoding.m 包含在目标编译源中
                  • NSString+URLEncoding.m 实现了 URLEncodedString 方法.
                  • 检查是否有僵尸.

                  我正在向 ShareKit 2.0 添加共享服务

                  I am adding a sharing service to ShareKit 2.0

                  标题:

                  @interface NSString (OAURLEncodingAdditions)
                  
                  - (NSString *)URLEncodedString;
                  

                  实现:

                  @implementation NSString (OAURLEncodingAdditions)
                  
                  - (NSString *)URLEncodedString 
                  {
                      NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
                                                                                             (CFStringRef)self,
                                                                                             NULL,
                                                                                             CFSTR("!*'();:@&=+$,/?%#[]"),
                                                                                             kCFStringEncodingUTF8);
                      [result autorelease];
                      return result;
                  }
                  

                  推荐答案

                  链接器存在问题,可能导致其死代码剥离完全忽略任何仅包含 obj-c 类别(或以其他方式未引用)的目标文件).理论上将 -ObjC 标志传递给链接器应该可以解决这个问题,但这似乎并不总是有效.您可以通过提供 -all_load 链接器标志来解决此问题,这将导致链接器始终链接所有目标文件.

                  There's an issue with the linker that can cause its dead-code stripping to completely omit any object files that only contain obj-c categories (or that are otherwise unreferenced). Theoretically passing the -ObjC flag to the linker should fix this, but that doesn't seem to always work. You can work around this issue by providing the -all_load linker flag, which will cause the linker to always link in all object files.

                  请注意,如果您的类别是您在某处包含的子项目或库的一部分,您可能必须在父项目上设置 -all_load.

                  Note that you might have to set -all_load on the parent project if your category is part of a sub-project or library that you-re including somewhere.

                  更新:我相信 -ObjC 现在是可靠的,并且多年来一直如此,因此您可以停止使用 -all_load 来解决这个问题.

                  Update: I believe -ObjC is reliable now and has been for years so you can stop using -all_load for this issue.

                  这篇关于iOS 5:使 NSString 类别包括 NSCFConstantString?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:info-plist 文件中没有所需的背景模式键 下一篇:如何隐藏在 ios 的文档目录中创建的文件夹?

                  相关文章

                  最新文章

                2. <legend id='Es0YQ'><style id='Es0YQ'><dir id='Es0YQ'><q id='Es0YQ'></q></dir></style></legend>

                    <bdo id='Es0YQ'></bdo><ul id='Es0YQ'></ul>

                    <tfoot id='Es0YQ'></tfoot>
                    1. <i id='Es0YQ'><tr id='Es0YQ'><dt id='Es0YQ'><q id='Es0YQ'><span id='Es0YQ'><b id='Es0YQ'><form id='Es0YQ'><ins id='Es0YQ'></ins><ul id='Es0YQ'></ul><sub id='Es0YQ'></sub></form><legend id='Es0YQ'></legend><bdo id='Es0YQ'><pre id='Es0YQ'><center id='Es0YQ'></center></pre></bdo></b><th id='Es0YQ'></th></span></q></dt></tr></i><div id='Es0YQ'><tfoot id='Es0YQ'></tfoot><dl id='Es0YQ'><fieldset id='Es0YQ'></fieldset></dl></div>

                      <small id='Es0YQ'></small><noframes id='Es0YQ'>