ios - Assigning a local @property for a UIView -
i have uiview .h , .m files , in main view controller have
popuprectangle *rectangeview = [[popuprectangle alloc] initwithframe:cgrectmake(0, 538, 320, 30)]
this allows me show rectangle, instead of doing in each function of view controller, want assign uiview local @property - available each function.
how done please ?
myclass.h
@interface myclass : uiviewcontroller @property (nonatomic, strong) popuprectangle *rectangeview; // public version @end
myclass.m
@interface myclass() // if don't want public remove if .h , add here instead @end @implementation myclass - (void)viewdidload { // alloc initwithframe here // _rectangeview getter rectangeview _rectangeview = [[popuprectangle alloc] initwithframe:cgrectmake(0, 538, 320, 30)]; } - (void)somerandommethodimadeup { // we're calling getter rectangeview again in different way, we're calling ivar. [[self rectangeview] sethidden:no]; } @end
as has been mentioned since know @property
why asking question. please read on apple documentation before asking simple , basic question seem know.
Comments
Post a Comment