我对iOS开发者网站上的某些项目感到困惑,需要解释。在下面的情况A,B中,属性/变量将会更新,但事实并非如此。 The page where the below code居住。
这些是属性/变量
self.badgeView.firstName
NSDate *originalDate
这是代码的两个片段:
NSMutableString *nameString = [NSMutableString stringWithString:@"John"];
self.badgeView.firstName = nameString;
[nameString appendString:@"ny"];
NSDate *originalDate = self.lastModificationDate;
self.lastModificationDate = [NSDate date];
NSLog(@"Last modification date changed from %@ to %@", originalDate, self.lastModificationDate);
答案 0 :(得分:3)
这些NSString
属性,如果实施正确方法,将复制您传递的参数。
NSMutableString *nameString = [NSMutableString stringWithString:@"John"];
self.badgeView.firstName = nameString;
[nameString appendString:@"ny"];
// you'll have to update it again, if you want that view's string updated:
self.badgeView.firstName = nameString;