2016-09-03 55 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") 
    }