Reputation: 5259
I have two classes.
GameData.h
#import "TeamData.h"
@property (assign, nonatomic) GameData* teamA;
TeamData.h
@interface TeamData : NSObject
@property (nonatomic, copy) NSString* teamName;
-(void) printTeamData;
A number of questions :
Inside GameData.m I have this code :
TeamData* team = self.teamA; [team printTeamData];
The first line shows this warning :
Incompatible pointer types from TeamData* with an expression of type TeamData*
Upvotes: 0
Views: 47
Reputation:
In GameData.h, your property points to its own class, not to TeamData
@property (assign, nonatomic) GameData* teamA;
assign
is meant for primitive types such as BOOL or NSInteger.
The parent class should hold a strong
reference to a child object.
So your property would be better off as
@property (strong, nonatomic) TeamData* teamA;
As for setting the teamA property, you would call setTeamA:
on your GameData
instance:
[myGameData setTeamA:...];
Upvotes: 1