#import <Foundation/Foundation.h>
@interface Engine : NSObject {
NSMutableString *mutableName;
}
@property (assign) NSMutableString *mutableName;
@end
なぜ私のivarは、engine.name
この単純なNSMutableString
方法では機能しないのですか?mutableName
はであり、NSMutableString
とで正しく実装されてい@property
ます@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;
}