Not able to set NSUserDefaults
<p>I have built an app that is used to manage the devices. And I set the details like server name , server port , UDID , ErID, and Language_pack_enabled at the time when the app launches using NSUserDefaults. But when I try to run the app , it crashes stating that it's a bad instruction and when I debugged it , the user defaults were set to nil . Can anyone tell me how to set the server name , port and ErID to the device which is there in the profile in the device as</p>

<blockquote>
  <p>(settings -> general -> device Management -> view details).</p>
</blockquote>

<p>Here's my code as follows</p>

<pre><code>let userDefaults : NSUserDefaults = NSUserDefaults.standardUserDefaults()
    let dict : AnyObject = userDefaults.objectForKey(mdmiosagent_Constants.MANAGED_APP_CONFIGURATION)!

    let serverName = dict[mdmiosagent_Constants.SERVERNAMEKEY] as! NSString?
    let serverPort = dict[mdmiosagent_Constants.SERVERPORTKEY] as! NSString?
    let UDID = dict[mdmiosagent_Constants.UDIDKEY] as! NSString?
    let languagePack = dict[mdmiosagent_Constants.IS_LANG_PACK_ENABLED] as! NSString?
    let ErID = dict[mdmiosagent_Constants.ERIDKEY] as! NSString?
</code></pre>