2016-09-03 54 views
0

我试图用这个简单的函数删除用户信息如下: -从火力dashbord删除整个节点

ref.child("UserProfile").child((FIRAuth.auth()?.currentUser?.uid)!).removeValueWithCompletionBlock({ (error, ref) in 
     if error != nil { 
     print(error) 
      } else { 
     print("Child Removed Correctly") 
     } 
}) 

的JSON树:

{ 
"Devices" : { 
"Nsguz6iIhUUeFPkcN9ge1KfQnGr1" : { 
    "Device1" : { 
    "Category" : "أخرى", 
    "Description" : "Hello", 
    "DeviceName" : "Test", 
    "ImageUrl" : "https://firebasestorage.googleapis.com/v0/b/jabeerah-c27c3.appspot.com/o/Devices_Images%2FF3E423AD-D259-4520-93D0-BC8BC9217ECB.png?alt=media&token=8c2f5c08-4293-4b2d-956a-265c9a7b3d02" 
    } 
}, 
"UserProfile" : { 
"0HjYidMRvPOxgCR8c8SSrLYUALm2" : { 
    "city" : "Jeddah", 
    "email" : "[email protected]", 
    "name" : "Hello", 
    "phone" : "00000" 
} 

} 
} 

我不断收到(运行时间错误)!

fatal error: unexpectedly found nil while unwrapping an Optional value

但实际上在仪表板中总是有一个值!

回答

1
FIRDatabase.database().reference().child("UserProfile").child(FIRAuth.auth()!.currentUser!.uid).removeValueWithCompletionBlock({ (error, refer) in 
    if error != nil { 
    print(error) 
     } else { 
    print(refer) 
    print("Child Removed Correctly") 
    }