ios - metadataquery deallocation before stopquery -


i'm using nsmetadataquery obtain list of files in icloud ubiquity documents directory in order populate tableview. code seems working, error stating query being deallocated without first calling stopquery. can't seem find discussion on topic. missing simple here?

here function query , notification:

var mymetadataquery : nsmetadataquery = nsmetadataquery() var cloudbackfiles : [anyobject] = [anyobject]()  func metadataforlistoffiles() {      mymetadataquery.predicate = nspredicate(format: "%k '*.sqlite'", nsmetadataitemfsnamekey)//change "%k '*.sqlite'"     mymetadataquery.searchscopes = [nsmetadataqueryubiquitousdocumentsscope]      nsnotificationcenter.defaultcenter().addobserver(self, selector: "metadataquerydidfinishgathering:", name: nsmetadataquerydidfinishgatheringnotification, object: mymetadataquery)      mymetadataquery.startquery()  }//metadataforlistoffiles  func metadataquerydidfinishgathering(notification : nsnotification) -> [anyobject] {      let query : nsmetadataquery = notification.object as! nsmetadataquery     query.disableupdates()      nsnotificationcenter.defaultcenter().removeobserver(self, name: nsmetadataquerydidfinishgatheringnotification, object: query)      query.stopquery()      let results = query.results      cloudbackfiles = []      if (query.resultcount >= 1) {         println("query.resultcount = \(query.resultcount)")          var = 0; < query.resultcount; i++ {             var forresultstring = results[i].valueforattribute(nsmetadataitemfsnamekey) as! string             println("results[\(i)].value = \(forresultstring)")             var forresultstringnoext = forresultstring.stringbydeletingpathextension             cloudbackfiles.append(forresultstringnoext)         }//for      } else {          println("the query.resultcount 0!")      }//if count else     println("cloudbackfiles list is: ")     println(cloudbackfiles)      //justfortest = results      return results  }//metadataquerydidfinishgathering(x) 

and error:

2015-04-24 22:49:38.367 [26397:2377464] being deallocated without first calling -stopquery. avoid race conditions, should first invoke -stopquery on run loop on -startquery called

any guidance appreciated.

i believe recursively calling metadata query. rewrote viewdidload , viewwillappear methods of tableview controller , believe code above working properly.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -