当我跑步时,我对此感到很疯狂:
Chord *chordA = [[Chord alloc] initWithLetter: @"A"];
Chord *chordC = [[Chord alloc] initWithLetter: @"C"];
Chord *chordE = [[Chord alloc] initWithLetter: @"E"];
NSLog(@"Letter: %@", chordC.letter);
NSLog输出“Letter:E”,但我期待字母C!
这是我的Chord.m:
#import "Chord.h"
@implementation Chord
NSString *_letter;
- (id) initWithLetter:(NSString *) letter{
self = [super init];
if(self){
_letter = letter;
}
return self;
}
- (NSString*) letter{
return _letter;
}
@end