I have a object I want to turn into an instance variable. This works:
ZipFile *newZipFile = [[ZipFile alloc] initWithFileName:zipPath mode:ZipFileModeCreate];
But when I try to change it to this it doesn’t work:
.h:
@interface PanelController : NSWindowController <NSWindowDelegate> {
ZipFile *_zipFile;
}
@property (nonatomic, assign) ZipFile *zipFile;
.m:
@synthesize zipFile = _zipFile;
...
// get a syntax error here
zipFile = [[ZipFile alloc] initWithFileName:zipPath mode:ZipFileModeCreate];
EDIT: I was able to fix this by putting this in my interface and getting rid of the @property:
ZipFile *newZipFile;
I guess I can’t assign setters and getters to just any object? But why won’t it work if I do:
ZipFile *zipFile;
There is no ivar named
zipFile. Did you mean:or:
Note: You probably want your property to be
retain.assignis for properties you do not own (like delegates).assignproperties are unsafe because can easily become dangling pointers.