1

Just after implementing a method for saving a users email and password from login into NSUserDefaults. My app crashes when running on iPhone 5s, but not in simulator (works as supposed).

Error message is:

dyld: Symbol not found: __TWPVSs26AutoreleasingUnsafePointerSs8_Pointer Referenced from: /private/var/mobile/Containers/Bundle/Application/76A645B8-3428-452F-AEA4-60BAF6C28819/AppName.app/AppName Expected in: /private/var/mobile/Containers/Bundle/Application/76A645B8-3428-452F-AEA4-60BAF6C28819/AppName.app/Frameworks/libswift_stdlib_core.dylib in /private/var/mobile/Containers/Bundle/Application/76A645B8-3428-452F-AEA4-60BAF6C28819/AppName.app/AppName

My NSUserDefaults code is this (don't think the rest matters):

let loggedIn = "yes"
let userDefaults = NSUserDefaults.standardUserDefaults()

userDefaults.setObject(email, forKey:"Email")
userDefaults.setObject(pw, forKey:"Password")
userDefaults.setObject(loggedIn, forKey: "LoggedIn")

userDefaults.synchronize()

This is set after user has entered email and password and the server has validated these and returned "ok".

In prepareForSegue I have this code:

let navigationController = segue.destinationViewController as UINavigationController

        let vc = navigationController.viewControllers[0] as LoggedInViewController

        // Gets email from saved data
        let userDefaults = NSUserDefaults.standardUserDefaults()
        let sendEmail: String = userDefaults.stringForKey("Email")
        userDefaults.synchronize()

        vc.email = sendEmail

Update: I have gone through the crash logs and noticed this: enter image description here

I dont really know how to read it but I noticed that exception code 0x0000000196442124 is at the bottom of my included image.

_dispatch_mach_msg_send + 1624

What does that mean? Does it help?

I have also marked all methods and stuff that has with NSUserDefaults (as seen above) as comments to see if they caused the problem. But the app crashes anyway..

Thanks in advance!

Simon Guldstrand
  • 488
  • 1
  • 5
  • 24

2 Answers2

0

The error message says something about autoreleasing memory. Do you have any ...Release() function calls within your swift code?

If so, comment them out and try again.

zisoft
  • 22,770
  • 10
  • 62
  • 73
  • Nope, no release() calls. Is there a way that I can see what row is affected? – Simon Guldstrand Jul 17 '14 at 12:01
  • Connect your device and you can use the debugger as usual (set breakpoints and step through the code). – zisoft Jul 17 '14 at 12:23
  • The problem is that I cannot get any breakpoints to work. As soon as the app launches. The error appears and all output from prints etc is gone. Only the error message as stated in the description remains.. – Simon Guldstrand Jul 17 '14 at 13:18
  • The only advice I can give you is to reduce your code until your app runs again without that error. Then put back your code step by step to determine the faulty piece. – zisoft Jul 17 '14 at 15:12
0

let sendEmail: String = userDefaults.stringForKey("Email")

for me swift is confused by lines like these and fails to correctly infer the type.
It performs ..... I don't what but it can't really get from anyobject! to string correctly it crashes when it tries to work with sendEmail

see:

Get from AnyObject(NSString) to String

Community
  • 1
  • 1
Daij-Djan
  • 49,552
  • 17
  • 113
  • 135