我正在尝试使用此代码在 NSMutableArray 中分配对象
- (IBAction)variablePressed:(UIButton *)sender {
NSString *variable = [sender currentTitle];
if (!_variableToBePassedIntoTheDictionary) _variableToBePassedIntoTheDictionary = [[NSMutableArray alloc] init];
[_variableToBePassedIntoTheDictionary replaceObjectAtIndex:0 withObject:variable];}
但是当我运行这个程序时,程序会在最后一行中断,因为我已将调试器设置为在引发异常时显示警告。在没有断点的情况下运行程序,程序给出 SIGARBT 并崩溃。然后我将这些值分配给一个字典,该字典将传递给模型以进行进一步计算。
- (IBAction)testVariableValues:(id)sender {
if (!_variablesAssignedInADictionary) _variablesAssignedInADictionary = [[NSMutableDictionary alloc] init];
[_variablesAssignedInADictionary setObject:_digitToBePassedIntoTheVariable forKey:_variableToBePassedIntoTheDictionary];
NSLog(@"%@", _variablesAssignedInADictionary);}
PS我是Objective C的新手,谁能解释一下我们什么时候使用
@synthesize someProperty;
对比
@synthesize someProperty = _someProperty;
谢谢你!