#import <Foundation/Foundation.h>
@interface Engine : NSObject {
NSMutableString *mutableName;
}
@property (assign) NSMutableString *mutableName;
@end
为什么我的 ivarengine.name
不能使用这种简单的NSMutableString
方法?mutableName
是NSMutableString
并且 已经正确地用@property
and实现了@synthesize
。
#import "Engine.h"
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Engine *engine = [[Engine alloc]init];
#import "Engine.h"
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Engine *engine = [[Engine alloc]init];
engine.mutableName = @"Jones";
[engine.mutableName insertString:@"Mrs." atIndex:0];
NSLog(@"Full name is %@", engine.mutableName);
}
[pool drain];
return 0;
}
#import "Engine.h"
@implementation Engine
@synthesize mutableName;
@end
#import "Engine.h"
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Engine *engine = [[Engine alloc]init];
engine.mutableName = @"Jones";
[engine.mutableName insertString:@"Mrs." atIndex:0];
NSLog(@"Full name is %@", name);
[pool drain];
return 0;
}