access a property in UIView in Viewcontroller?
I have been given a project to edit. I think this is a simple question but want to explain it in detail.I usually开发者_JAVA百科 set up iPhone projects with interface builder and then have a view controller h and m file.
However this has been set up in a different way I am new to, the view has been coded.
The h file is a simple viewcontroller class like this:
@interface MainViewController : UIViewController
{
}
- (id)init;
@end
And then the m file has this:
@interface MainView : UIView
{
NSUinterger firstinterger;
}
- (id)initWithImages:(NSArray *)inImages;
@end
And then it has the @implementation MainView
just after that with lots more code.
Further down however is where I need to add my code just after
@end
@implementation MainViewController
But I need to access the NSUinterger named first integer and I am unable to. I have tried a few ways of synthesizing etc. but I think I am doing it wrong. How I would get the value of it? I can access it in the code before the @implementation MainViewController
but not after which is where I need it.
Synthesize the variable in MainView
. Have an instance of the MainView
in MainViewController
and then you can access it by
MainView *mv = [[MainView alloc] init];
mv.firstInteger // gives you the variable.
NSUinterger firstinterger
in your code shows no ';' at the end of that line, do you get compilation errors or is it just a typo in your question?
精彩评论