Bug has been resolved

was due to data race from multiple calls to firbase when a new user is created, had to resolve by making call order sequential
This commit is contained in:
Okechi Onyeje 2016-11-26 11:00:49 -05:00
parent 8a616052d9
commit 9f85f3fdc3
5 changed files with 147 additions and 18 deletions

View File

@ -186,7 +186,7 @@
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/CategoriesTableViewController.swift"
timestampString = "501863904.741449"
timestampString = "501868546.548886"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "570"
@ -201,7 +201,7 @@
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/CategoriesTableViewController.swift"
timestampString = "501863904.74155"
timestampString = "501868546.549061"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "572"
@ -744,7 +744,7 @@
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/SettingsViewController.swift"
timestampString = "501863904.765008"
timestampString = "501868546.567523"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "194"
@ -759,7 +759,7 @@
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/SettingsViewController.swift"
timestampString = "501863904.765171"
timestampString = "501868546.567615"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "197"
@ -881,5 +881,132 @@
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/HomeViewController.swift"
timestampString = "501867900.667754"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "16"
endingLineNumber = "16"
landmarkName = "HomeViewController"
landmarkType = "3">
<Locations>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "Vendoo.HomeViewController.firebaseManager.getter : Vendoo.FirebaseManager"
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/HomeViewController.swift"
timestampString = "501868546.571367"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "16"
endingLineNumber = "16"
offsetFromSymbolStart = "35">
</Location>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "Vendoo.HomeViewController.init (nibName : Swift.Optional&lt;Swift.String&gt;, bundle : Swift.Optional&lt;__ObjC.NSBundle&gt;) -&gt; Vendoo.HomeViewController"
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/HomeViewController.swift"
timestampString = "501868546.571482"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "16"
endingLineNumber = "16"
offsetFromSymbolStart = "143">
</Location>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "Vendoo.HomeViewController.init (coder : __ObjC.NSCoder) -&gt; Swift.Optional&lt;Vendoo.HomeViewController&gt;"
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/HomeViewController.swift"
timestampString = "501868546.571568"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "16"
endingLineNumber = "16"
offsetFromSymbolStart = "83">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/FirebaseManager.swift"
timestampString = "501868545.010904"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "31"
endingLineNumber = "31"
landmarkName = "init()"
landmarkType = "5">
<Locations>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "Vendoo.FirebaseManager.init () -&gt; Vendoo.FirebaseManager"
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/FirebaseManager.swift"
timestampString = "501868546.572473"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "31"
endingLineNumber = "31"
offsetFromSymbolStart = "1491">
</Location>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "Vendoo.FirebaseManager.(init () -&gt; Vendoo.FirebaseManager).(closure #1)"
moduleName = "Vendoo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/FirebaseManager.swift"
timestampString = "501868546.572569"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "34"
endingLineNumber = "34"
offsetFromSymbolStart = "19">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Vendoo/FirebaseManager.swift"
timestampString = "501868545.010904"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "34"
endingLineNumber = "34"
landmarkName = "init()"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

View File

@ -2,6 +2,7 @@
// FirebaseService.swift
// Vendoo
//
// This class is responsible for initializing a new user, as well as managing web request to both firebase database and data storage
// Created by Okechi Onyeje on 6/2/16.
// Copyright © 2016 Okechi Onyeje. All rights reserved.
//
@ -19,6 +20,7 @@ class FirebaseManager: NSObject {
let user_email = ((NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!).stringByReplacingOccurrencesOfString(".", withString: "_")
let storage = FIRStorage.storage()
var indicator = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.WhiteLarge)
var firGroup = dispatch_group_create()
//let key: String!
@ -26,18 +28,20 @@ class FirebaseManager: NSObject {
super.init()
indicator.color = UIColor.blueColor()
//check if user has been created
dispatch_group_enter(self.firGroup)
self.ref.child("Users").observeSingleEventOfType(.Value, withBlock: { snapshot in
// do some stuff once
if(!snapshot.hasChild(self.user_email)){
let user = ["name": (NSUserDefaults.standardUserDefaults().objectForKey("name") as? String)!, "user_Listings": "", "listing_Keys": "", "favorite_listings_keys": ""]
self.ref.child("Users").child(self.user_email).setValue(user)
self.ref.child("Users").child(self.user_email).setValue(user, withCompletionBlock: {
(error, reference) -> Void in
dispatch_group_leave(self.firGroup)
})
}
})
}
}

View File

@ -27,7 +27,7 @@ class HomeViewController: UITabBarController {
ServiceNotificationManager.delegate = self
self.notificationsManager.setManagers(fbGraphManager, fireManager: firebaseManager, ebayManager: ebayGraphManager, etsyManager: etsyManager)
// Do any additional setup after loading the view.
dispatch_async(dispatch_get_main_queue(), {
dispatch_group_notify(self.firebaseManager.firGroup, dispatch_get_main_queue(), {
//get all listing information for current user
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").observeSingleEventOfType( .Value, withBlock: {

View File

@ -61,13 +61,11 @@ extension SignUpViewController {
return
}
else{
//save user account
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "signedIn")
NSUserDefaults.standardUserDefaults().setObject(self.email.text, forKey: "email")
NSUserDefaults.standardUserDefaults().setObject(self.name.text, forKey: "name")
//save user credentials in Keychain
do{
try Locksmith.saveData(["pass": self.password.text!], forUserAccount: self.email.text!, inService: "vendoo")