I / m为iOS 7开发并使用arc。我正在尝试创建一个包含NSMutableArray并且遇到麻烦的shred实例。 在我的头文件中,我有以下
#import <Foundation/Foundation.h>
@interface SharedDataController : NSObject
@property (nonatomic, retain) NSString *text1;
@property (nonatomic, retain) NSString *text2;
@property (nonatomic, retain) NSString *text3;
@property (nonatomic, retain) NSMutableArray *qrcodes;
+(id) sharedInstance;
@end
并且在我的意图中
@synthesize text1,text2,text3, qrcodes;
+(id) sharedInstance
{
static id sharedInstance = nil;
if (sharedInstance == nil) {
NSLog(@"creating shared instance contoller");
sharedInstance = [[self alloc] init];
}
return sharedInstance;
}
@end
当我尝试将对象添加到数组
时SharedDataController *sharedDataController = [SharedDataController sharedInstance];
[sharedDataController.qrcodes addObject:result.text];
NSLog(@"%@", sharedDataController.qrcodes);
我没有,我到底做错了什么?