У меня есть 3 btns для установки свойства. Но при нажатии "exc_bad_access" произошел сбой. Я запускаю его на iOS5 с помощью ARC. Я использую шаблон alloc + init, но все равно не получилось. Я не знаю почему.
@property (strong, nonatomic) NSDictionary *testVariableValues;
@synthesize testVariableValues = _testVariableValues;
- (NSDictionary *)testVariableValues
{
if (!_testVariableValues) {
_testVariableValues = [[NSDictionary alloc] initWithObjectsAndKeys:@"0", @"x",@"0", @"a",@"0", @"b", nil]];
}
return _testVariableValues;
}
- (IBAction)testPressed:(UIButton *)sender
{
if ([@"Test 1" isEqualToString:sender.currentTitle]) {
self.testVariableValues = [NSDictionary dictionaryWithObjectsAndKeys:@"1", @"x", @"2", @"a", "3", "b", nil];
} else if([@"Test 2" isEqualToString:sender.currentTitle]) {
self.testVariableValues = [NSDictionary dictionaryWithObjectsAndKeys:@"-4", @"x", @"3", @"a", "4", "b", nil];
} else if([@"Test 3" isEqualToString:sender.currentTitle]) {
self.testVariableValues = nil;
}
}