有人可以向我解释为什么这个简单的任务不起作用
这是代码
loanDetails.currency = myCurrency;
NSLog(@" Value %@",myCurrency);
NSLog(@" Value %@",loanDetails.currency);
NSLog(@" Value %@",myCurrency);
输出为: -
2010-05-05 23:00:44.394 ExpenseTracker[3576:207] Value AFA
2010-05-05 23:00:44.750 ExpenseTracker[3576:207] Value (null)
2010-05-05 23:00:45.095 ExpenseTracker[3576:207] Value AFA
定义如下:
@property (nonatomic,retain) NSString *currency;
答案 0 :(得分:2)
loadDetails
是否为空?
答案 1 :(得分:0)
好吧,当你写loanDetails.currency = myCurrency
时,这相当于调用[loanDetails setCurrency:myCurrency]
。那么,看一下你的标题:你是不是偶然定义了它readonly
?你有合成访问器方法还是自己编写?