Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[NSTaggedPointerString objectAtIndex:]: unrecognized selector sent to instance

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

Some details about the app:

  • multi language support
  • using storyboards
  • My app used user defined runtime attributes which 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 )

Logs from 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
like image 663
Webdevotion Avatar asked Oct 26 '15 12:10

Webdevotion


2 Answers

You should set an array to "AppleLanguages" not string

In other words :

Replace this

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

With this :

NSUserDefaults.standardUserDefaults().setObject( ["en-BE"], forKey: "AppleLanguages" )
like image 181
Husam Avatar answered Oct 04 '22 21:10

Husam


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() ){
    // ...
}
like image 44
Webdevotion Avatar answered Oct 04 '22 23:10

Webdevotion