xcode [NSTaggedPointerString objectAtIndex:]:无法识别的选择器发送到实例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33345389/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:06:54  来源:igfitidea点击:

[NSTaggedPointerString objectAtIndex:]: unrecognized selector sent to instance

iosxcodeuitextfieldswift2first-responder

提问by Webdevotion

I have a problem with everyUITextfield in my app. Whenever an instance of UITextfield becomes first responder, my app crashes with the following error message.

我的应用程序中的每个UITextfield都有问题。每当 UITextfield 的实例成为第一响应者时,我的应用程序就会崩溃并显示以下错误消息。

Some details about the app:

有关该应用程序的一些详细信息:

  • multi language support
  • using storyboards
  • My app used user defined runtime attributeswhich I'm trying to get rid of ( legacy of using the PixateFreestyle SDK to style the UI ), but there are still some of those attributes in the storyboards left.
  • Testing on real devices
  • I have set a symbolic breakpoint on [NSTaggedPointerString objectAtIndex:]but it does not seem to catch the error before the app itself crashes
  • iOS 8 SDK / Swift / Xcode 7.1 ( happened on Xcode 7 too )
  • 多语言支持
  • 使用故事板
  • 我的应用程序使用user defined runtime attributes了我试图摆脱的(使用 PixateFreestyle SDK 设置 UI 样式的遗留问题),但故事板中仍然存在一些这些属性。
  • 在真实设备上测试
  • 我已经设置了一个符号断点,[NSTaggedPointerString objectAtIndex:]但它似乎没有在应用程序本身崩溃之前捕获错误
  • iOS 8 SDK / Swift / Xcode 7.1(也发生在 Xcode 7 上)

Logs from Xcode:

来自 Xcode 的日志:

2015-10-26 12:49:16.034 MY_APP[1477:641273] -[NSTaggedPointerString objectAtIndex:]: 
unrecognized selector sent to instance 0xa00000000006c6e2
2015-10-26 12:49:16.034 MY_APP[1477:641273] *** Terminating app due to uncaught 
exception 'NSInvalidArgumentException', 
reason: '-[NSTaggedPointerString objectAtIndex:]: unrecognised selector 
sent to instance 0xa00000000006c6e2'
*** First throw call stack:
(0x18334cf48 0x1987f7f80 0x183353c5c 0x183350c00 0x183254cac
0x1832f8c4c 0x183292f84 0x18923ecbc 0x194b8c6f0 0x188924e8c 0x188924bb0
0x1889247b0 0x188924560 0x1889244cc 0x188cf00c8 0x188924310 0x188922b24
0x188ceb028 0x18890ad44 0x18890aad4 0x188ceaa4c 0x188cf2ef8 0x18890dac4
0x1889070b8 0x188906bec 0x18896809c 0x188968448 0x1889ef814 0x188aa01a8
0x188a9f65c 0x188e5b330 0x188a84b5c 0x18891285c 0x188e5c70c 0x1888d18b8
0x1888ce63c 0x1889106cc 0x18890fcc8 0x1888e04a4 0x1888de76c 0x183304544
0x183303fd8 0x183301cd8 0x183230ca0 0x18e7b4088 0x188948ffc 0x10033ae58
0x19903a8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

回答by Husam

You should set an array to "AppleLanguages"not string

您应该将数组设置"AppleLanguages"为非字符串

In other words :

换句话说 :

Replace this

替换这个

NSUserDefaults.standardUserDefaults().setObject( "en-BE", forKey: "AppleLanguages" )

With this :

有了这个 :

NSUserDefaults.standardUserDefaults().setObject( ["en-BE"], forKey: "AppleLanguages" )

回答by Webdevotion

After I removed this piece of code in the app, the bug was fixed.

在应用程序中删除这段代码后,该错误已修复。

NSUserDefaults.standardUserDefaults().removeObjectForKey("AppleLanguages")
NSUserDefaults.standardUserDefaults().setObject( "en-BE", forKey: "AppleLanguages" )
if( NSUserDefaults.standardUserDefaults().synchronize() ){
    // ...
}