简体   繁体   中英

App Crashes after launch screen

I have a big project that was initially running on objective c and now i have converted to swift 2.2 using xcode 7.3 with optimising the code . But the App crashes saying EXC_BAD_INSTRUCTION.. I know there must be something wrong .. This is the line that is generating

 var dict : [NSObject : AnyObject] = userDefaults.objectForKey(mdmiosagent_Constants.MANAGED_APP_CONFIGURATION) as! [NSObject : AnyObject]

And same thing is shown here as well

 0x10a553f09 <+171>: movq   0xd692d8(%rip), %rbx      ; (void *)0x000000010c04ad70: objc_release

Has Anyone got any idea what particularly must have gone wrong ? Let me know If any more information about the code is to be provided.

I think there are a couple of things that could be wrong with this line:

userDefaults.objectForKey(mdmiosagent_Constants.MANAGED_APP_CONFIGURATION) as! [NSObject : AnyObject]

  1. Your userDefaults does not actually contain any value for mdmiosagent_Constants.MANAGED_APP_CONFIGURATION
  2. You are force casting with as! , that might also lead to problems if the contents you get back isn't [NSObject: AnyObject]

So you could try to check if your userDefaults actually contains a value for mdmiosagent_Constants.MANAGED_APP_CONFIGURATION .

If it does, then what the contents? Try not to force cast it for a start and just see what it is.

Hope that helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM