简单的任务不适合我:iphone sdk

时间:2010-05-05 21:07:27

标签: iphone iphone-sdk-3.0

有人可以向我解释为什么这个简单的任务不起作用 这是代码
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;

2 个答案:

答案 0 :(得分:2)

loadDetails是否为空?

答案 1 :(得分:0)

好吧,当你写loanDetails.currency = myCurrency时,这相当于调用[loanDetails setCurrency:myCurrency]。那么,看一下你的标题:你是不是偶然定义了它readonly?你有合成访问器方法还是自己编写?