我有一个财产(noARC)
@property (nonatomic, retain) NSString *itemUUID;
和初始化
- (void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if (_itemUUID) {
[self updateViews];
} else {
_itemUUID = [[EADataManager sharedInstance] generateUuidString];
NSLog(@"%@", _itemUUID);
}
}
UUID生成方法是
- (NSString *)generateUuidString
{
CFUUIDRef UUID = CFUUIDCreate(kCFAllocatorDefault);
NSString *uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, UUID);
[uuidString autorelease];
CFRelease(UUID);
return uuidString;
}
我尝试在另一种方法中以非常简单的方式使用此属性:
- (IBAction)submitButton:(id)sender
{
if ([nameField.text length] > 3)
{
NSLog(@"%@", _itemUUID);
NSDictionary *changedData = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:nameField.text, priceField.text, quantityField.text, nil] forKeys:[NSArray arrayWithObjects: @"Name", @"Price", @"Quantity", @"UUID", nil]];
}
}
所以在第二个NSLog
有一个例外BAD_ACCESS
。无法理解我的错。