2
if let userID = NSUserDefaults.standardUserDefaults().valueForKey("uid") as? String{

            currentUser = User(name: snapshot.value["name"] as! String ,phoneNumber: snapshot.value["phoneNumber"] as! String, userId: userID ,  isOnline: snapshot.value["isOnline"] as! Bool, key: "", lastName: snapshot.value["lastName"] as! String, photoUrl: "")

        }

Im using Firebase as MBaas and Im getting this error at the currentUser line, curiously this isn't happening all the time,but only sometimes when I am leaving the app (home button) or reentering its occurs..
Thanks for your time.

jerem
  • 1,016
  • 2
  • 12
  • 27

2 Answers2

8

try this (swift 3)

(userID as AnyObject).integerValue
Gulz
  • 1,773
  • 19
  • 15
5

You are trying to convert a string into number that's why this happens

Durai Amuthan.H
  • 31,670
  • 10
  • 160
  • 241