I’ve just starting out with obj-c and I created 2 files, a .h and a .m file. The .h file is..
#import <Foundation/Foundation.h>
@interface CardUnit : NSObject
{
@private
NSString *_name;
NSString *_gold;
}
@property (nonatomic, assign) NSString *name;
@property (nonatomic, assign) NSString *gold;
@end
and the .m file is
#import "CardUnit.h"
@implementation CardUnit
@synthesize gold = _gold;
@synthesize name = _name;
@end
But it’s giving me 2 errors on the @synthesize lines, which are…
“Existing ivar “_gold” for property gold with assign attribute must be __unsafe retained” and the same for name.
From the error i see you are using ARC, Automatic Reference Counting .
Basically you can get rid of all the @synthesize statements and even the private declarations of the ivar’s name and gold is not necessary.
All you need is the CardUnit.h to be like this :
The Xcode compiler will take care of the rest.
See also this reply on SO