我在下面有一个自定义类:
#import <Foundation/Foundation.h>
@interface NamesFix : NSObject
@property (nonatomic, copy) NSString *fixedName;
- (NSString *)fixName:(NSString *)name;
@end
实现文件:
#import "NamesFix.h"
@implementation NamesFix
@synthesize fixedName;
- (NSString *)fixName:(NSString *)name
{
if ([name isEqualToString:@"Foo"])
{
self.fixedName = @"Bar";
}
else
{
self.fixedName = @"";
}
return self.fixedName;
}
当我通过以下方式访问我的自定义类时:
NamesFix *namesFix = [NamesFix alloc] init];
NSString *someString = @"Foo";
[namesFix fixName:someString];
NSLog(@"fixedName: %@", namesFix.fixedName];
固定名称返回null
。我哪里弄错了?