ios - Use UILabel in Class Method -


so have this:

@interface viewcontroller : uiviewcontroller{     iboutlet uilabel *screen; }  +(void)num:(int)number; 

and want access screen in class in num method so:

+(void)num:(int)number{     screen.text = @"test"; } 

but xcode says

"instance variable 'screen' accesses in class method"

is there way this?

yes, reason not letting because + sign in method denotes class method aka called on viewcontroller class don't have reference specific screen outlet.

change + - , able call method like

[self num:7] 

and access screen outlet in method

hope helps!


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -