ios - NSUserDefaults setObject method causes the app to crash in ios8 -


I am getting an app in which I am passing some data between the view controller with NSUserDefaults.

This is the code given below.

  [[NSUserDefaults standard user default] Set object: selectedLists forKey: UserID];   

Where Selected list is NSMutableArray and userID is NSString .

This code works fine till Ios7 and xcode5.

Since I have updated xcode 6 and now i am using ios8, my app works fine with xcode 6 and iOS 7.1, but the app crashes when i am in iOS 8 devices The app will run. Error occurred below

  Exception occurred 'NSInvalidArgumentException', due to reason the application ended: '- [__ NSCFNumber length]: Non-recognized selector example sent for 0x7a027060'  < / Pre> 

If someone had to face this problem with iOS 8, please help me.

Thanks in advance.

Selected list

  {CardFace = Word; ImportFlag = Import; ListID = 1; List name = "adjective - appearance"; Quizzie = Definition; UserID = 1; }   

and UserId is 1.

Edit

  *** Throwdown call stack: (0 CoreFoundation 0x06a24df6 __exceptionPreprocess + 182 1 libobjc.A.dylib 0x03ac8a97 objc_exception_throw + 44 2 CoreFoundation 0x06a2ca75 - [Nsbjekt (Nsbjekt) Doasnottrekgnijeselector:] 277 3 CoreFoundation 0x069759c7 ___forwarding___ + 1047 4 CoreFoundation 0x0697558e _kf_forwarding_prep_0 + 14 5 CoreFoundation 0x068df30f CFStringGetLength + 143 6 CoreFoundation 0x069de510 _sfaprefsenkdaekevluaparintomessge + 64 7 CoreFoundation 0x06a275cf - [Sfaprefsplistsurs Sendmessgesettingvlua: Forky:] 111 8 CoreFoundation 0x06954f3a - [CFPrefsPlistSource alreadylocked_setValue: forKey:] + 250 9 CoreFoundation 0x06954e22 - [CFPrefsSource setValue: forKey:] 82 10 CoreFoundation 0x06954dc3 ___CFPreferencesSetValueWithContainer_block_invoke + 51 11 Core Forwarding 0x0690ef0a + [CFFSS Source With Sforaidiantifayr User: By Host: Container: SHOW] + 1274 12 core Forwardeshn 0x06954d61 _CFPreferencesSetValueWithContainer + 225 13 CoreFoundation 0x06a0aa62 _CFPreferencesSetAppValueWithContainer + 66 14 Foundation 0x0347f53f - [NSUserDefaults (NSUserDefaults) setObject: forKey:] 59 15 Foundation 0x0353eeba - [NSUserDefaults ( NSKeyValueCoding) setValue: forKey:] 68 16 Vocab 0x000eaecc Vocab + 720,588 17 libobjc A.dylib 0x03ade7cd - [NSObject performSelector: withObject: withObject:] 84 18 UIKit 0x022a079d - [UIApplication sendAction: To: forEvent:] 99 19 UIKit 0x022a072f - [UIApplication sendAction: toTarget: fromSender: forEvent:] + 64 20 UIKit 0x023d3a16 - [UC control sender: From: Event:] + 69 21UIKET 0x023D3E 33 - [UIControl_SandActionForEventAvent: Avent:] + 598 22UIKET 0x023D309D - [UICInTrOr touch touches: Avent:] + 660 23UiKT 0x022FTB - [UI window * SandoutForDocument:] + 874 24 UIKit 0x022f1595 - [UIWindow sendEvent:] 791 25 UIKit 0x022b6aa9 - [UIApplication sendEvent:] 242 26 UIKit 0x022c68de _UI Applictionhandliventfromkueueevent + 20,690 27 UIKit 0x0229b0 79 _uiapplictionhandliventkeue + 2206 28 CoreFoundation 0x069487bf __kfruँlup_is_kaling_aut_to_a_surs0_prform_fnkshn__ + 15 29 CoreFoundation 0x0693e2cd __kfruँlupdaosorses0 + 253 30 CoreFoundation 0x0693d828 __kfruँluprun + 952 31 CoreFoundation 0x0693d1ab CFRunLoopRunSpecific + 443 32 CoreFoundation 0x0693cfdb CFRunLoopRunInMode + 123 33 0x0436424f 0x0436408c GSEventRun + 104 35 UIKit 0x0229ee16 UIApplicationMain GSEventRunModal + 192 34 GraphicsServices GraphicsServices + 1526 36 Vocab 0x0004c9bc Vocab + 72124 37 libdyld.dylib start 0x03ee6ac9 +1) libc ++ abi.dylib: type NSException ends with the unexpected exception of  

Edit on the selection method of my tableviews ...

  UserID = [[Users TAO ObjectAntindex: IndexPath.ro] Valufei: @ "UserId"];   

Where users are an array.

You should check the UserID type because the crash NSArray < / Code> to NSMutableArray is not related to changing.

You must mislead NSNN with NSSSNING on your user ID:

Change your code and use variable user id string instead of user ID

  NSString userIDString; // If UserID is a class of NSNumber, its value is changed to NSString if ([UserID is KindOfClass: [NSNumber class]]) {userIDString = [UserID stringValue]; } And userIDString = UserID;    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -