swift - call generic function without params -
protocol idatasource:anyobject{ typealias ds; typealias u; func datasource(ds:ds, index:int?); func datasource(ds:ds, data:[u]); } class datasource<t:anyobject>{ var map = [nsmanagedobjectid:t](); var data = [t](); var ctrls:nshashtable = nshashtable.weakobjectshashtable(); func find(value:t)->int?; var selected:t?; func setneedsupdate<bar:idatasource bar.u==t,bar.ds==dsgen>(){ ctrl in self.ctrls.allobjects { let client = ctrl as! bar; client.datasource(self, data:self.data); } } func foo(){ // error setneedsupdate() } }
how can call method setneedsupdate()? compiler error " cannot invoke 'setneedsupdate' no arguments"
have found decision, decision demand parameter
func setneedsupdate<bar:idatasource bar.u==t,bar.ds==dsgen>(type:bar.type){ ctrl in self.ctrls.allobjects { let client = ctrl as! bar; client.datasource(self, data:self.data); } } func foo<bar:idatasource bar.u==t,bar.ds==dsgen>(){ // error setneedsupdate(bar.self) }
Comments
Post a Comment