swift - Pausing an observeEventType Firebase -


i have observeeventtype function, , transitionblock in ios app. both of them using same ref, causing app crash @ observeeventtype

  self.ref.child("data").child("lynes").observeeventtype(firdataeventtype.value, withblock: { (snapshot) in             print(snapshot.value!)             self.removeall()              var data = snapshot.value! as! [string: anyobject]              //code crashes on line above              (key, value) in data {                 print("\(key) -> \(value["name"]!)")                     dataarray.append(key)                     locarray.append(value["location"] as! string)                 namearray.append(value["name"] as! string)                 totalarray.append(value["total"] as! int)             }               self.configuresearchcontroller()              print(dataarray)              self.tableview.reloaddata()               // ...         }) 

error: not cast value of type 'nsnull' (0x10df0f600) 'nsdictionary' (0x10df0efe8).

and transitionblock being called after button click on view:

self.ref.child("data").runtransactionblock({ (currentdata: firmutabledata) -> firtransactionresult in         if var post = currentdata.value as? [string : anyobject], let uid = firauth.auth()?.currentuser?.uid {.... 

is there way pause event continuously listening change in data, , instead, run after transition block completes?

alright, ended doing writing simple if statement, catching if null existed.

if let data =  snapshot.value! as? [string: anyobject] {                 (key, value) in data {                     print("\(key) -> \(value["name"]!)")                     dataarray.append(key)                     locarray.append(value["location"] as! string)                     namearray.append(value["name"] as! string)                     totalarray.append(value["total"] as! int) }} 

it's workaround when null error comes up.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -