iphone - Using NSTimer in NSObject class -


i displaying custom uiview (which uialertview) on clicking button in many view controllers.so, have included code in nsobject class. have display uitableview subview custom view, , 1 of uitableview cell contains countdown timer. able display customview , uitableview. but, not able implement nstimer in customview.

code display custom view:

+(nsmutabledictionary *) printpopup:(uiview *)inputview {     int i=20;      uiview *mycustomview = [[uiview alloc] initwithframe:cgrectmake(20, 100, 280, 250)];     [mycustomview setbackgroundcolor:[uicolor colorwithred:(247/255.0) green:(239/255.0) blue:(218/255.0) alpha:1]];     uitableview *dynamictable=[[uitableview alloc]initwithframe:cgrectmake(0, 0, 280, 250) style:uitableviewstyleplain];     dynamictable.tag=55;     [mycustomview addsubview:dynamictable];         uibutton *cancelbutton = [uibutton buttonwithtype:uibuttontyperoundedrect];     //    [cancelbutton settitle:@"cancel" forstate:uicontrolstatenormal];     [cancelbutton setbackgroundimage:[uiimage imagenamed:@"delete3.png"] forstate:uicontrolstatenormal];     [cancelbutton setframe:cgrectmake(250, 0, 30, 30)];     cancelbutton.tag=i+7;     [mycustomview addsubview:cancelbutton];     [inputview addsubview:mycustomview];     [uiview animatewithduration:0.4f animations:^{         [mycustomview setalpha:1.0f];     }];     nsmutabledictionary *returneddic=[[nsmutabledictionary alloc]init];     [returneddic setobject:dynamictable forkey:@"tableview"];     [returneddic setobject:cancelbutton forkey:@"cancelbutton"];     return returneddic;  }  + (void)dismisscustomview:(uibutton *)sender {     [uiview animatewithduration:0.2f animations:^{         [sender.superview setalpha:0.0f];     }completion:^(bool done){         [sender.superview removefromsuperview];     }];  } 

when trying implement nstimer in nsobject class, getting following error:

instance variable accessed in class method 

i have call nstimer in class. there alternatives.

please suggest.

the syntax using defining methods of class methods (the little + before return type). if want instance methods should prefixed minus sign -. since seem require access instance variables, methods should instance methods.

note instance methods still have access of static "class" variables.


Popular posts from this blog

Php - Delimiter must not be alphanumeric or backslash -

trac - Modifying workflow to add a status and split on ticket type -

Delphi interface implements -