Exception when create UISwitch in iOS6.1

An.NgoAn.Ngo VNMember

Hi everyone,

I have a bug with newest version of Xamarin.iOS (version 7.2.4.4) when running on iOS 6.1 Simulator (iOS 7 work ok). Do any one have any idea about what happen ?

2014-06-27 10:49:08.310 OneMangaiOS[1598:a07] -[__NSCFString count]: unrecognized selector sent to instance 0x7be2b340

(GAIUncaughtExceptionHandler.m:49): Uncaught exception: -[__NSCFString count]: unrecognized selector sent to instance 0x7be2b340
2014-06-27 10:49:39.371 OneMangaiOS[1598:a07] Unhandled managed exception: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[__NSCFString count]: unrecognized selector sent to instance 0x7be2b340 (MonoTouch.Foundation.MonoTouchException)
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:IntPtr_objc_msgSend (intptr,intptr)
at MonoTouch.UIKit.UISwitch..ctor () [0x00016] in /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/UISwitch.g.cs:71
at CrossUI.Touch.Dialog.Elements.BooleanElement.CreateSwitch () [0x00000] in :0
at CrossUI.Touch.Dialog.Elements.BooleanElement.GetCellImpl (MonoTouch.UIKit.UITableView tv) [0x00000] in :0
at OneManga.iOS.Elements.CustomBooleanElement.GetCellImpl (MonoTouch.UIKit.UITableView tv) [0x00003] in /Users/ngothaian/DATA/Projects/one-manga-client/OneManga.iOS/Views/Elements/CustomElements.cs:113
at CrossUI.Touch.Dialog.Elements.Element.GetCell (MonoTouch.UIKit.UITableView tv) [0x00000] in :0
at CrossUI.Touch.Dialog.DialogViewController+Source.GetCell (MonoTouch.UIKit.UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) [0x00000] in :0
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at MangaProject.Application.Main (System.String[] args) [0x00008] in /Users/ngothaian/DATA/Projects/one-manga-client/OneManga.iOS/Main.cs:17
mono-rt: Stacktrace:

mono-rt:
Native stacktrace:

mono-rt: 0 OneMangaiOS 0x00253537 mono_handle_native_sigsegv + 327

mono-rt: 1 OneMangaiOS 0x0025e37a sigabrt_signal_handler + 122

mono-rt: 2 libsystem_platform.dylib 0x051abdeb _sigtramp + 43

mono-rt: 3 ??? 0xffffffff 0x0 + 4294967295

mono-rt: 4 libsystem_sim_c.dylib 0x04bded8b abort + 140

mono-rt: 5 OneMangaiOS 0x003dc8f3 monotouch_unhandled_exception_handler + 291

mono-rt: 6 OneMangaiOS 0x00253d7b mono_invoke_unhandled_exception_hook + 91

mono-rt: 7 OneMangaiOS 0x00252d8c mono_handle_exception_internal + 6620

mono-rt: 8 OneMangaiOS 0x002513a9 mono_handle_exception + 41

mono-rt: 9 OneMangaiOS 0x001ebb99 mono_x86_throw_exception + 137

mono-rt: 10 ??? 0x0d06ae57 0x0 + 218541655

mono-rt: 11 OneMangaiOS 0x003cbdc1 monotouch_exception_handler + 177

mono-rt: 12 OneMangaiOS 0x000168b5 GAIUncaughtExceptionHandler + 843

mono-rt: 13 CoreFoundation 0x04994318 __handleUncaughtException + 728

mono-rt: 14 libobjc.A.dylib 0x0472f0b9 _ZL15_objc_terminatev + 86

mono-rt: 15 libc++abi.dylib 0x04d63a65 _ZL19safe_handler_callerPFvvE + 13

mono-rt: 16 libc++abi.dylib 0x04d63acd __cxa_bad_typeid + 0

mono-rt: 17 libc++abi.dylib 0x04d64bc2 _ZL23__gxx_exception_cleanup19_Unwind_Reason_CodeP17_Unwind_Exception + 0

mono-rt: 18 libobjc.A.dylib 0x0472ef89 _ZL26_objc_exception_destructorPv + 0

mono-rt: 19 CoreFoundation 0x049964bd -[NSObject(NSObject) doesNotRecognizeSelector:] + 253

mono-rt: 20 CoreFoundation 0x048fabbc forwarding + 588

mono-rt: 21 CoreFoundation 0x048fa94e _CF_forwarding_prep_0 + 14

mono-rt: 22 CoreFoundation 0x0488cb10 CFArrayGetCount + 80

mono-rt: 23 UIKit 0x03588c04 __36-[_UISwitchInternalView _labelImage]_block_invoke_0 + 144

mono-rt: 24 UIKit 0x035be2fe +[UIImage(_UIImageTintedInterfaceExtension) _cachedImageForKey:fromBlock:] + 131

mono-rt: 25 UIKit 0x03588b6c -[_UISwitchInternalView _labelImage] + 187

mono-rt: 26 UIKit 0x0358a6ed -[_UISwitchInternalView _buildControl] + 1454

mono-rt: 27 UIKit 0x035877c1 __39-[_UISwitchInternalView initWithFrame:]_block_invoke_0 + 36

mono-rt: 28 UIKit 0x033ce40c +[UIView(Animation) _performWithoutAnimation:] + 82

mono-rt: 29 UIKit 0x03587793 -[_UISwitchInternalView initWithFrame:] + 420

mono-rt: 30 UIKit 0x0358b196 -[UISwitch _commonInitNewLook] + 225

mono-rt: 31 UIKit 0x0358b741 -[UISwitch initWithFrame:] + 143

mono-rt: 32 UIKit 0x0358b6ab -[UISwitch init] + 118

mono-rt: 33 ??? 0x0eb5818c 0x0 + 246776204

mono-rt: 34 ??? 0x1d3f7354 0x0 + 490697556

mono-rt: 35 ??? 0x1d3f71d0 0x0 + 490697168

mono-rt: 36 ??? 0x1d3f6e98 0x0 + 490696344

mono-rt: 37 ??? 0x1d3f6c70 0x0 + 490695792

mono-rt: 38 ??? 0x1d3d2767 0x0 + 490547047

mono-rt: 39 ??? 0x1d3d2560 0x0 + 490546528

mono-rt: 40 ??? 0x1d3d2700 0x0 + 490546944

mono-rt: 41 OneMangaiOS 0x0028531b mono_jit_runtime_invoke + 843

mono-rt: 42 OneMangaiOS 0x0032391f mono_runtime_invoke + 127

mono-rt: 43 OneMangaiOS 0x003d35ef monotouch_trampoline + 4991

mono-rt: 44 UIKit 0x0343e8fb -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 412

mono-rt: 45 UIKit 0x0343e9cf -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 69

mono-rt: 46 UIKit 0x034271bb -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1863

mono-rt: 47 UIKit 0x03437b4b -[UITableView layoutSubviews] + 241

mono-rt: 48 UIKit 0x033d42dd -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 279

mono-rt: 49 libobjc.A.dylib 0x047426b0 -[NSObject performSelector:withObject:] + 70

mono-rt: 50 QuartzCore 0x0125bfc0 -[CALayer layoutSublayers] + 240

mono-rt: 51 QuartzCore 0x0125033c _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 468

mono-rt: 52 QuartzCore 0x01250150 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26

mono-rt: 53 QuartzCore 0x011ce0bc _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 324

mono-rt: 54 QuartzCore 0x011cf227 _ZN2CA11Transaction6commitEv + 395

mono-rt: 55 QuartzCore 0x011cf8e2 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 96

mono-rt: 56 CoreFoundation 0x048d3afe CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 30

mono-rt: 57 CoreFoundation 0x048d3a3d __CFRunLoopDoObservers + 381

mono-rt: 58 CoreFoundation 0x048b17c2 __CFRunLoopRun + 1106

mono-rt: 59 CoreFoundation 0x048b0f44 CFRunLoopRunSpecific + 276

mono-rt: 60 CoreFoundation 0x048b0e1b CFRunLoopRunInMode + 123

mono-rt: 61 GraphicsServices 0x05dd47e3 GSEventRunModal + 88

mono-rt: 62 GraphicsServices 0x05dd4668 GSEventRun + 104

mono-rt: 63 UIKit 0x03383ffc UIApplicationMain + 1211

mono-rt: 64 ??? 0x0eb4f6a8 0x0 + 246740648

mono-rt: 65 ??? 0x0eb4d5c4 0x0 + 246732228

mono-rt: 66 ??? 0x0eb4d1a0 0x0 + 246731168

mono-rt: 67 ??? 0x0eb4d2df 0x0 + 246731487

mono-rt: 68 OneMangaiOS 0x0028531b mono_jit_runtime_invoke + 843

mono-rt: 69 OneMangaiOS 0x0032391f mono_runtime_invoke + 127

mono-rt: 70 OneMangaiOS 0x00329431 mono_runtime_exec_main + 401

mono-rt: 71 OneMangaiOS 0x003291f4 mono_runtime_run_main + 628

mono-rt: 72 OneMangaiOS 0x001e3dbd mono_jit_exec + 93

mono-rt: 73 OneMangaiOS 0x003c4830 main + 2784

mono-rt: 74 libdyld.dylib 0x04f24701 start + 1

Posts

  • An.NgoAn.Ngo VNMember

    Hi adamkemp, I think it is the same problem as mine but I still don't know how to solve it yet :(

  • adamkempadamkemp USInsider, Developer Group Leader mod

    Are you using the "AppleLanguages" preferences key? In the case of the StackOverflow post that key was being set to a value that was a single string instead of an array of strings. Make sure you're not doing the same thing.

  • An.NgoAn.Ngo VNMember

    I had figured it out recently. My project use MVVMCross with Settings plugins from https://github.com/aritchie/acrmvvmcross. Every time I call Resync method of the plugin, I can't instance UISwitch anymore, I think the method have done something that corrupt the user settings file. It is solved now, since I switch to another plugin.

    Thank you for helping me,

  • AllanRitchie-oldAllanRitchie-old CAInsider ✭✭✭

    Resync isn't really meant to be called by outside libraries. There shouldn't be a need, though resync should not be firing the clear event

  • An.NgoAn.Ngo VNMember

    I think I misunderstood by reading method name. I call it to force save the data into disk just like NSUserDefaults.Synchronize.

  • CheesebaronCheesebaron DKInsider, University mod

    Synchronize is called on Line 24, 32 and 37. So there is no need to worry about it.

  • AllanRitchie-oldAllanRitchie-old CAInsider ✭✭✭

    I sent a fix to nuget this evening. It filters out these ios settings by default. It also fixes the issue with resync calling clear behind the scenes.

    Resync is used to rebuild the observable dictionary just in case you are modifying settings somewhere else in your app outside of this setting component.

  • An.NgoAn.Ngo VNMember

    Thank Allan, that's good new. I will re-use your plugin for our next release, since it is the best Settings plugin out there.

Sign In or Register to comment.