dispatch_group_notify从未调用过

时间:2016-06-07 01:47:41

标签: ios swift grand-central-dispatch dispatch

我有以下概述的代码,但最后调用dispatch_group_notify。永远不会发生

    // Get friends:
    dispatch_group_enter(self.dbGetQueue)
        getFriends.observeSingleEventOfType(.Value, withBlock: { snapshot in
            for detailData in snapshot.children {

                print(detailData)

                self.friends.append(Member(userID: detailData.key, userName: detailData.value!["userName"] as! String))

            }
        dispatch_group_leave(self.dbGetQueue)
        })


    // Get group memebers:
    dispatch_group_enter(self.dbGetQueue)
        getGroupMembers.observeSingleEventOfType(.Value, withBlock: { snapshot in
            for groupMemberDetail in snapshot.children {

                print(groupMemberDetail)
                if groupMemberDetail.key != FeastGlobal.sharedInstance.userID {

                    self.groupMembers.append(groupMemberDetail.key)

                }
            }
        })

    // Get group invites presently out:
    dispatch_group_enter(self.dbGetQueue)
        getFriendMemberInvites.observeSingleEventOfType(.Value, withBlock: { snapshot in
            for groupInvitePresentlySentDetail in snapshot.children {

                self.groupInvitesSent.append(groupInvitePresentlySentDetail.key)
            }
        dispatch_group_leave(self.dbGetQueue)
        })

    dispatch_group_notify(self.dbGetQueue, dispatch_get_main_queue()) {
        // Final load of who is left of conacts (not user or friend)

        // Have list of friends, now set to iterate through:
        // 0: not invited yet, 1: invited (eiter declined or not replied yet) not , 2: Already a member -- will have alert noting user became a group member
        print(self.groupMembers.count)
        print(self.friends.count)
        print(self.groupInvitesSent.count)


        for aFriend in self.friends {

            print("Friends name is: " + aFriend.userName)

            var inviteStatus = Invite(userName: aFriend.userName, status: "not invited yet", statusSort: 0, name: aFriend.userName, userID: aFriend.userID)

            if self.groupMembers.contains(aFriend.userID) {

                inviteStatus.statusSort = 2
                inviteStatus.status = "member"

                self.memberStatuses.append(inviteStatus)

            } else if self.groupInvitesSent.contains(aFriend.userID){

                inviteStatus.statusSort = 1
                inviteStatus.status = "invited"

                self.memberStatuses.append(inviteStatus)

            } else {

                self.memberStatuses.append(inviteStatus)

            }
        }

        self.tableView.reloadData()
    }

这可以减轻吗?

0 个答案:

没有答案