Tag: firebase swift2 firebase

Firebase,Swift:`runTransactionBlock()`返回null

每次我运行runTransactionBlock它给我空 ,虽然有一个节点在那个位置: – FIRMutableData(最上面的事务)(null) 在线上: – print(totalPost) func updateTotalNoOfPost(){ let prntRef = FIRDatabase.database().reference().child("TotalPosts") prntRef.observeSingleEventOfType(.Value, withBlock: {(totalSnap) in if totalSnap.exists(){ prntRef.child("noOfTotalPost").runTransactionBlock({ (totalPost: FIRMutableData) -> FIRTransactionResult in print(FIRAuth.auth()!.currentUser!.uid)//Giving me correct userID print(totalPost)//<Null> print(prntRef.child("noOfTotalPost"))//Giving me correct path to that node totalPost.value = totalPost.value as! Int + 1 return FIRTransactionResult.successWithValue(totalPost) }, andCompletionBlock: { (err, TF, snap) in print(err?.localizedDescription) print(TF) […]

从Firebase中检索数据后,如何将检索到的数据从一个视图控制器发送到另一个视图控制器?

这是我在Firebase中创build的表格。 我有一个searchbutton。 button动作将首先从firebase中获取数据,然后将其发送到另一个视图控制器,并将显示在一个表视图。 但主要问题是在从Firebase获取所有数据之前 self.performSegueWithIdentifier("SearchResultPage", sender: self ) 触发器和我的下一个视图控制器显示一个空的表视图。 这里是我的努力。 从这里我觉得我的代码放置不好。

在Firebase中保存数组

我使用的是Firebase 3.0作为后端,我需要将每个user.uid保存在一个需要成为NSArray的独立子user.uid中,然后使用for循环检索该数组! 这是我如何保存我的数据:我已经为FIRController创build了一个单独的类,它正在处理数据库和存储的所有存储和检索。 func signUpUserWithBasicInfo(emailId : String! , password : String!, username : String!, age : String, gender : String!, backpackerType : String, info : [String : AnyObject], completionBlock : (() -> Void)){ print("fir signup did recieve") FIRAuth.auth()?.createUserWithEmail(emailId, password: password, completion: { user,error in if error != nil{ print("error encountered while backend email signup Handshake […]

我如何创build一个关于显示名称,用户名和个人资料图片信息的用户?

我如何创build一个关于显示名称,用户名和个人资料图片信息的用户? 我可以使用这个代码吗? if let user = FIRAuth.auth()?.currentUser let name = user.displayName let email = user.email let photoUrl = user.photoURL let uid = user.uid; // The user's ID, unique to the Firebase project. // Do NOT use this value to authenticate with // your backend server, if you have one. Use // getTokenWithCompletion:completion: instead. } else […]

Firebase在swift中查询sorting顺序?

当我将以下Firebase数据库数据加载到我的tableView中时,数据按date升序sorting。 我怎样才能降序(显示最新的post在顶部)? 在Xcode中查询: let ref = self.rootRef.child("posts").queryOrderedByChild("date").observeEventType(.ChildAdded, withBlock: { (snapshot) -> Void in JSON导出: "posts" : { "-KMFYKt7rmfZINetx1hF" : { "date" : "07/09/16 12:46 PM", "postedBy" : "sJUCytVIWmX7CgmrypqNai8vGBg2", "status" : "test" }, "-KMFYZeJmgvmnqZ4OhT_" : { "date" : "07/09/16 12:47 PM", "postedBy" : "sJUCytVIWmX7CgmrypqNai8vGBg2", "status" : "test" }, 谢谢!! 编辑:下面的代码是整个解决scheme,由于Bawpotter 更新的查询: let ref = self.rootRef.child("posts").queryOrderedByChild("date").observeEventType(.ChildAdded, withBlock: […]