是否可以禁用has_one
关联中的所有缓存?
我们希望将实例方法更改为关联,但不希望冒关联缓存的副作用(例如this)。
我们还希望使用(true)
(http://guides.rubyonrails.org/association_basics.html#controlling-caching)在关联级别消除它,而不是每次使用。
答案 0 :(得分:2)
在某些情况下,NSString *cellText = selectedCell.textLabel.text;
NSArray *components = [cellText componentsSeparatedByString:@" "];
if (components.count > 0) {
NSString *firstPart = components[0];
NSLog(@"%@", firstPart);
}
选项(http://guides.rubyonrails.org/association_basics.html#bi-directional-associations)应该可以防止过时的关联对象。