ios - No known class method for selector when using blocks -


i new use block syntax , facing below problem. below code calling static method of class causing problem. below code called click of next button on bar . there mistake on syntax of code?

-(bool) shouldperformseguewithidentifier:(nsstring *)identifier sender:(id)sender     {         if (![sender iskindofclass:[uibarbuttonitem class] ]) {             return true;         }         // trim spaces         self.stewardsnametextfield.text = [self.stewardsnametextfield.text stringbytrimmingcharactersinset:[nscharacterset whitespacecharacterset] ];      self.tracknametextfield.text = [self.tracknametextfield.text stringbytrimmingcharactersinset:[nscharacterset whitespacecharacterset] ];      self.curatornametextfield.text = [self.curatornametextfield.text stringbytrimmingcharactersinset:[nscharacterset whitespacecharacterset] ];       bool isvalid =[jltvalidator validatefields: @[self.stewardsnametextfield, self.tracknametextfield, self.curatornametextfield, self.weatherconditionsegment, self.trackconditionsegment] withscrolltocallback: ^(uiview * invalidfield) // problem here. incorrect syntax?             {                 if (invalidfield == self.stewardsnametextfield || invalidfield == self.tracknametextfield || invalidfield == self.curatornametextfield)                 {                     [invalidfield becomefirstresponder];                 }                 else                 {                     uiedgeinsets contentinsets = uiedgeinsetszero;                     cgpoint top = cgpointmake(0, invalidfield.frame.origin.y - 90);                      [_scrollview setcontentoffset:top animated:yes];                     _scrollview.scrollindicatorinsets=contentinsets;                 }                  if (!isvalid) {                     uialertview *alert = [[uialertview alloc] initwithtitle:@"sorry!" message:@"please fill out marked fields." delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil, nil];                     [alert show];                 }                  return isvalid;             }];  } 

the definition of static method being called class:

+(bool)validatefields:(nsarray *)fields     {         return [jltvalidator validatefields:fields withscrolltocallback:nil];     }     +(bool)validatefields:(nsarray *)fields andshoulddisplaymessage : (bool) shoulddisplaymessage     {         return [jltvalidator validatefields:fields withscrolltocallback:nil andshoulddisplaymessage:shoulddisplaymessage];     }  +(bool)validatefields:(nsarray *)fields withscrolltocallback : (void (^) (uiview *))scrolltocallback {     return [jltvalidator validatefields:fields withscrolltocallback:scrolltocallback andshoulddisplaymessage:true]; }  +(bool)validatefields:(nsarray *)fields withscrolltocallback : (void (^) (uiview *))scrolltocallback andshoulddisplaymessage : (bool) shoulddisplaymessage {  } 

whats wrong here? pls guide.

+(bool)validatefields:(nsarray *)fields withscrolltocallback : (void (^) (uiview *))scrolltocallback 

the block parameter in method doesn't return (you can see 'void' there). if inside block, return bool value (isvalid) incorrect. moreover, returned value you're trying (isvalid = ..... isvalid) mistake.

i don't know u're trying inside block, solve this, can below:

bool isvalid =[jltvalidator validatefields: @[self.stewardsnametextfield, self.tracknametextfield, self.curatornametextfield, self.weatherconditionsegment, self.trackconditionsegment] withscrolltocallback: ^(uiview * invalidfield) // problem here. incorrect syntax?         {             if (invalidfield == self.stewardsnametextfield || invalidfield == self.tracknametextfield || invalidfield == self.curatornametextfield)             {                 [invalidfield becomefirstresponder];             }             else             {                 uiedgeinsets contentinsets = uiedgeinsetszero;                 cgpoint top = cgpointmake(0, invalidfield.frame.origin.y - 90);                  [_scrollview setcontentoffset:top animated:yes];                 _scrollview.scrollindicatorinsets=contentinsets;             }         }];  if (!isvalid) {     uialertview *alert = [[uialertview alloc] initwithtitle:@"sorry!" message:@"please fill out marked fields." delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil, nil];     [alert show]; } 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -