无论我做什么,我似乎都无法初始化这些属性中的任何一个,我总是得到 0 或 null 作为输出。
Player.h:
@interface Player : NSObject
{
NSString *name;
}
@property (nonatomic, strong) NSString *name;
@end
Player.m:
@implementation Player
@synthesize name;
@end
MainGameDisplay.h:
#import "Player.h"
@interface MainGameDisplay : UIViewController<UIScrollViewDelegate>
{
Player *player, *rival1, *rival2, *rival3;
}
MainGameDisplay.m:
-(void) initCharAttributes {
player = [[Player alloc] init];
player.name = @"PlayerName";
NSLog(@"NAME:%@", player.name); //Output= NAME:(null)
}