swift - PFObject subclass gets "Cannot convert value of type 'Match' to expected argument type '@noescape (AnyObject) throws -> Bool'" error -


i'm getting following error when calling indexof on array of subclass of pfobject.

cannot convert value of type 'match' expected argument type '@noescape (anyobject) throws -> bool'

my class:

class match: pfobject, pfsubclassing {xxxx} 

the method error happening:

    func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : anyobject]) {     //dismiss image picker     self.dismissviewcontrolleranimated(true) { () -> void in         //wait dismissal in case there error show         let recordedvideofileurl = info[uiimagepickercontrollermediaurl] as? nsurl          if let recordedvideofileurl = recordedvideofileurl         {             //upload file s3                         {                 let uploadrequest = try s3uploadmanager.uploadfile(self.match!.localpathtovideo()!)                  self.match!.saveeventually({ (success: bool, error: nserror?) -> void in                     if (success)                     {                         // object has been saved.                         self.matchescontroller.loadobjects()                          //set progress tracking upload                         uploadrequest.uploadprogress = {[weak self](bytessent:int64, totalbytessent:int64, totalbytesexpectedtosend:int64) -> void  in                             if let match = self?.match                             {       >>>>>>error here           var index = self?.matchescontroller.objects?.indexof(match)                             }                         }                     }                  })             }             catch             {                 // todo: handle error             }         }     } } 

from read only, error happens when object contained in array not conform equatable extension. pfobject inherits nsobject conform extension. i'm @ loss...

any pointers appreciated

found solution. turns out objects method on pfquerytableviewcontroller returns [anyobject], need cast [match]

let objects = self?.matchescontroller.objects as! [pfobject] 

and works...

i'm still new @ swift , parse, seem wrong objects method return [anyobject]? given comment in doc

/*!  @abstract array of instances of <pfobject> used data source.  */ public var objects: [anyobject]? { } 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -