I am probably overlooking something small, but I cant seem to figure it out.
I am attempting to pass an instance of a custom class to an instance of another custom class.
NOTE: I am using ARC*
The second custom class is set up:
#import "OneArtsDay.h"
@interface SocialButton : UIButton {
OneArtsDay *artsDay;
}
@property (nonatomic) OneArtsDay *artsDay;
- (void)setArtsDay:(OneArtsDay *)day;
@end
and
#import "SocialButton.h"
@implementation SocialButton
@synthesize artsDay;
- (void)setArtsDay:(OneArtsDay *)day {
if (day ==nil) {
NSLog(@"Error, cannot set artsDay");
}
else {
artsDay = day;
}
}
@end
Now, when I call these commands in code:
SocialButton *social = [[SocialButton alloc] init];
OneArtsDay *day = [[OneArtsDay alloc] init];
//Do things with day here//
[social setArtsDay:day];
I am still given an error when I try to access the property OneArtsDay *artsDay. What am I missing?
The property should be declared strong. Here’s how I code the same thing: