iOS NSMutableAttributedString Crash With unrecognized selector - ios

Help!
the crash happens at :
[emtionString replaceCharactersInRange:range withString:imageAndRangeDicArray[i][#"image"]];
When NSMutableAttributedString is replaced with attributeString
This is the stack trace:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMutableAttributedString _encodingCantBeStoredInEightBitCFString]: unrecognized selector sent to instance 0x7fe8f34f52f0'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107e95f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000107b2ebb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000107e9d04d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000107df527c ___forwarding___ + 988
4 CoreFoundation 0x0000000107df4e18 _CF_forwarding_prep_0 + 120
5 CoreFoundation 0x0000000107db8195 __CFStringCheckAndReplace + 597
6 CoreFoundation 0x0000000107db7f1b -[__NSCFString replaceCharactersInRange:withString:] + 27
7 Foundation 0x00000001076da63e -[NSConcreteMutableAttributedString replaceCharactersInRange:withString:] + 337

What types are emtionString and imageAndRangeDicArray[i][#"image"]?
According to the docs, that method wants an NSString as the withString.
If you're passing in an NSAttributedString instead it won't work. (It seems like NSAttributedString should be a subclass of NSString but it's not.)

Related

Xcode 8 Simulator crash if changing device type

I am working around with Xcode 8. But I have one problem, specifically when I try to change the device type in simulator, it crashes and I get a crash message
*** Terminating app due to uncaught exception 'NSRangeException', reason:
'*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
0 CoreFoundation 0x0000000103b5934b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001035ba21e objc_exception_throw + 48
2 CoreFoundation 0x0000000103a8af1b -[__NSArrayM objectAtIndex:] + 203
3 Mahroosa 0x0000000102e207c7 -[MainViewController viewSliderControllerAtIndex:] + 151
4 Mahroosa 0x0000000102e21117 -[MainViewController LoadSlides] + 1495
5 Mahroosa 0x0000000102e25b32 -[MainViewController TimerTick:] + 98
6 Foundation 0x0000000103115144 __NSFireTimer + 83
7 CoreFoundation 0x0000000103aeb964 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
8 CoreFoundation 0x0000000103aeb5f3 __CFRunLoopDoTimer + 1075
9 CoreFoundation 0x0000000103aeb17a __CFRunLoopDoTimers + 250
10 CoreFoundation 0x0000000103ae2f01 __CFRunLoopRun + 2065
11 CoreFoundation 0x0000000103ae2494 CFRunLoopRunSpecific + 420
12 GraphicsServices 0x0000000108f2ca6f GSEventRunModal + 161
13 UIKit 0x00000001048ebf34 UIApplicationMain + 159
14 Mahroosa 0x0000000102e34a2f main + 111
15 libdyld.dylib 0x000000010628868d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Any ideas?.
Thanks in advance!

Swift 3: -[_SwiftValue mergeType]: unrecognized selector sent to instance

I am getting a '-[_SwiftValue mergeType]: unrecognized selector sent to instance' error whenever I try to save a managed object context after doing a delete or an update of a record. For example:
context.delete(managedObject)
follow by
context.save()
and yes, context.save() is in a do-try-catch.
Records insert just fine, but the delete is throwing an exception. Stack trace is as follows:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_SwiftValue mergeType]: unrecognized selector sent to instance 0x60800005b0f0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010afac34b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010a5f021e objc_exception_throw + 48
2 CoreFoundation 0x000000010b01bf34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010af31c15 ___forwarding___ + 1013
4 CoreFoundation 0x000000010af31798 _CF_forwarding_prep_0 + 120
5 CoreData 0x000000010aae203a -[NSManagedObjectContext(_NSInternalAdditions) _validateObjects:forOperation:error:exhaustive:forSave:] + 1946
6 CoreData 0x000000010aae1836 -[NSManagedObjectContext(_NSInternalAdditions) _validateChangesForSave:] + 422
7 CoreData 0x000000010aae1476 -[NSManagedObjectContext(_NSInternalChangeProcessing) _prepareForPushChanges:] + 214
8 CoreData 0x000000010aaddeb2 -[NSManagedObjectContext save:] + 562
Trace starts right after it leaves my code.
Any insight would be helpful.
You may get this error when you use code like this, to set a merge policy:
context.mergePolicy = NSMergePolicyType.mergeByPropertyStoreTrumpMergePolicyType
Instead use this:
context.mergePolicy = NSMergePolicy(merge: .mergeByPropertyStoreTrumpMergePolicyType)

Objective-C category for NSMutableDictionary not being respected in iOS10

I have an app written in Objective-C with a category for NSMutableDictionary. In iOS9, the app works fine. However when run in iOS10, the app crashes due to an 'unrecognized selector sent to instance'. I've isolated the problem to the NSMutableDictionary category not being respected in iOS10.
The category for NSMutableDictionary includes the following method:
- (id)getObjectForStringKeyPath:(NSString *)keysPath {
NSArray *dividedString = [keysPath componentsSeparatedByString:#"/"];
return [self getObjectForKeyPath:dividedString];
}
The line which it is crashing at is (response is type 'id'):
NSArray *textArray = [response getObjectForStringKeyPath:"someText/text"];
I've checked the response from the server and the response is valid. Also as I mentioned the crash does not happen on iOS9. It only happens on iOS10.
Does anyone know how to solve this, or any approaches to take for this problem?
Crash log
-[__NSSingleEntryDictionaryI getObjectForStringKeyPath:]: unrecognized selector sent to instance 0x608000a3f3e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSSingleEntryDictionaryI getObjectForStringKeyPath:]: unrecognized selector sent to instance 0x608000a3f3e0'
*** First throw call stack:
(
0 CoreFoundation 0x000000011036034b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010fdc121e objc_exception_throw + 48
2 CoreFoundation 0x00000001103cff34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00000001102e5c15 ___forwarding___ + 1013
4 CoreFoundation 0x00000001102e5798 _CF_forwarding_prep_0 + 120
5 XYZApp 0x000000010c919b7e __64-[XYZController configureConditionsTextFromHTML:]_block_invoke + 126
6 XYZApp 0x000000010c8e973f __41-[XYZDataProvider getTermsAndConditions:]_block_invoke + 159
7 XYZApp 0x000000010c8fd5ae -[XYZManager handleSuccessfulResponse:andResponseBlock:] + 110
8 XYZApp 0x000000010c8fbede __50-[XYZManager GET:withParameters:andResponseBlock:]_block_invoke + 126
9 libdispatch.dylib 0x0000000110872980 _dispatch_call_block_and_release + 12
10 libdispatch.dylib 0x000000011089c0cd _dispatch_client_callout + 8
11 libdispatch.dylib 0x000000011087ca1d _dispatch_main_queue_callback_4CF + 733
12 CoreFoundation 0x00000001103244f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 CoreFoundation 0x00000001102e9f8d __CFRunLoopRun + 2205
14 CoreFoundation 0x00000001102e9494 CFRunLoopRunSpecific + 420
15 GraphicsServices 0x00000001131c9a6f GSEventRunModal + 161
16 UIKit 0x000000010e573f34 UIApplicationMain + 159
17 XYZApp 0x000000010c92698f main + 111
18 libdyld.dylib 0x00000001108e868d start + 1
19 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
The error says that the object type is __NSSingleEntryDictionaryI, not the NSMutableDictionary that you expect.
Make a mutable copy of the dictionary that the server gives you and assign that to response.
For some undocumented reason, iOS10 believes the object type is an NSDictionary, so I created a category for NSDictionary with the getObjectForStringKeyPath method. This was the cleanest and most efficient solution for my problem.

Xcode 6.1 Swift Thread 1 Sigabrt Error

2015-04-14 23:35:17.143 Yellow Ninja 2.0[12492:594324]
-[Yellow_Ninja_2_0.ACWallGenerator generatewall]: unrecognized selector sent to instance 0x7faf38fb7ce0 2015-04-14 23:35:17.146
Yellow Ninja 2.0[12492:594324] * Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason:
'-[Yellow_Ninja_2_0.ACWallGenerator generatewall]: unrecognized
selector sent to instance 0x7faf38fb7ce0'
* First throw call stack: ( 0 CoreFoundation 0x000000010fc77f35 exceptionPreprocess + 165 1 libobjc.A.dylib
0x0000000111bb4bb7 objc_exception_throw + 45 2 CoreFoundation
0x000000010fc7f04d -[NSObject(NSObject) doesNotRecognizeSelector:] +
205 3 CoreFoundation 0x000000010fbd727c
___forwarding_ + 988 4 CoreFoundation 0x000000010fbd6e18 _CF_forwarding_prep_0 + 120 5 Foundation
0x00000001102ef2b4 NSFireTimer + 83 6 CoreFoundation
0x000000010fbdff64
__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 20 7 CoreFoundation 0x000000010fbdfb25
__CFRunLoopDoTimer + 1045 8 CoreFoundation 0x000000010fba2e5d __CFRunLoopRun + 1901 9 CoreFoundation
0x000000010fba2486 CFRunLoopRunSpecific + 470 10 GraphicsServices
0x00000001170249f0 GSEventRunModal + 161 11 UIKit
0x00000001108fc420 UIApplicationMain + 1282 12 Yellow Ninja 2.0
0x000000010fa7a5be top_level_code + 78 13 Yellow Ninja 2.0
0x000000010fa7a5fa main + 42 14 libdyld.dylib
0x00000001123a0145 start + 1 15 ???
0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with
uncaught exception of type NSException (lldb)
This is the error message that came up whenever I try to run my app. Any suggestions please? It says "InvalidArgumentException"??? Thanks!
You have set up a timer to call generatewall when it fires. But either you have no generatewall method — for example, if it takes a parameter, then it is called generatewall:, with a colon — or you have neglected to expose that method to Objective-C.

Apple AWT Internal Exception: -[NSView CGLPBufferObj]: unrecognized selector sent to instance 0x7fc73d201960

I'm trying to start an application with some native jogl libraries under mac. It runs on linux and windows. The error message is:
2012-10-26 16:35:49.160 java[1440:1703] invalid drawable
2012-10-26 16:35:49.163 java[1440:1703] -[NSView CGLPBufferObj]: unrecognized selector sent to instance 0x7fc73d201960
2012-10-26 16:35:49.164 java[1440:1703] Apple AWT Internal Exception: -[NSView CGLPBufferObj]: unrecognized selector sent to instance 0x7fc73d201960
2012-10-26 16:35:49.165 java[1440:1703] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSView CGLPBufferObj]: unrecognized selector sent to instance 0x7fc73d201960'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff929e60a6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8f7533f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff92a7c6ea -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
3 CoreFoundation 0x00007fff929d45ce ___forwarding___ + 414
4 CoreFoundation 0x00007fff929d43b8 _CF_forwarding_prep_0 + 232
5 AppKit 0x00007fff8c6395be -[NSOpenGLContext setPixelBuffer:cubeMapFace:mipMapLevel:currentVirtualScreen:] + 59
6 libjogl_desktop.jnilib 0x00000001284708cb setContextPBuffer + 203
7 libjogl_desktop.jnilib 0x00000001284d428b Java_jogamp_opengl_macosx_cgl_CGL_setContextPBuffer__JJ + 43
8 ??? 0x000000010790ef90 0x0 + 4421906320
)
libc++abi.dylib: terminate called throwing an exception
Process finished with exit code 134
Any idea?

Resources