我有以下简单的类定义:
//mycommon.h
@interface CurrentPath : NSObject
@property (nonatomic, strong) NSString* PathString;
@property (nonatomic, strong) NSMutableArray* PathArr;
- (void) addAddressToPath:(NSString*) address;
@end
//mycommon.m
@implementation CurrentPath : NSObject
@synthesize PathString;
@synthesize PathArr;
- (void) addAddressToPath:(NSString*) address{
NSLog(@"addAddressToPath...");
// Add to string
self.PathString = [self.PathString stringByAppendingString:address];
// Add to Arr
[self.PathArr addObject:address];
}
@end
在另一个类中,我这样做#import<mycommon.h>
并声明变量是这样的:
@interface myDetailViewController :
{
CurrentPath* currentPath;
}
- (void) mymethod;
@end
并且在
@implementation myDetailViewController
- void mymethod{
self->currentPath = [[CurrentPath alloc] init];
NSString* stateSelected = @"simple";
[self->currentPath addAddressToPath:stateSelected];
}
@end
问题是 self->currentPath 的 PathString 和 PathArr 属性在此方法调用后为空,我认为其中应该包含“简单”。请帮忙!