在下面的代码中,我理解为什么-(void)addData:(NSString *)text{
//provided your self.greekLetter is NSMutableArray
[self.greekLetter addObject:text]
NSIndexPath *index = [NSIndexPath indexPathForRow:(self.greekLetter.count - 1) inSection:0];
[self.tableview insertRowsAtIndexPaths:@[index] withRowAnimation:UITableViewRowAnimationRight];
}
已更改为person.name
,但我不完全理解为什么"john"
不会在内存中引用person
, undefined
在下一行。
obj = undefined
var person = { name: "wtf" };
function doStuff(obj) {
obj.name = "john";
obj = undefined;
}
doStuff(person);
现在等于person.name
和john
仍然引用或"点"到对象而不是"指向"在记忆中没有任何东西,即未定义。我可以在学习中继续前进,只需依靠这种方式就可以这样工作,但我永远无法清楚地说明为什么它会这样运作。
答案 0 :(得分:2)
函数调用中的obj
参数传递给person
的引用
doStuff(person);
参数值是person
中存储的对象引用的副本。因此,当您为obj
变量赋予新值时,这对person
没有影响。