I have created a certain class to represent an object. My program has several views and view controllers. I want the different view controllers to work with this object. However, when I try to synthesize the class members so that they can be used in the view controller, I get an error saying that there is no declaration of the property found in the interface, even after I have included the .h file. How can I synthesize members from another class in the various view controllers that will be working with them?
+2
A:
Without seeing your code or the specific compiler errors, it's hard to say what might be going on.
If you're just setting up a simple model object, then you should be able to write something like this in Model.h
:
@interface Model : NSObject {}
@property (nonatomic, retain) NSString *name;
@end
and in your Model.m
file:
@implementation Model
@synthesize name;
@end
All you need to do at that point is #import "Model.h"
into your other source files and then you can use the name
property like so:
Model *m = [[Model alloc] init];
m.name = @"Bob";
...
It sounds like the compiler is complaining about the lack of the @property
declaration in your case.
Chris Parker
2010-09-05 06:03:50
I am creating the property I just didn't write anything in the m file. That was the problem.
awakeFromNib
2010-09-05 06:30:30