简体   繁体   English

简单的作业对我不起作用:iPhone SDK

[英]simple assignment not working for me: iphone sdk

Can someone please explain to me why this simple assignment doesn't work. 有人可以向我解释为什么这个简单的任务不起作用。
Here is the code 这是代码
loanDetails.currency = myCurrency;
NSLog(@" Value %@",myCurrency);
NSLog(@" Value %@",loanDetails.currency);
NSLog(@" Value %@",myCurrency);

the output is:- 输出为:-
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

And the definition is as: 定义为:

@property (nonatomic,retain) NSString *currency;

loadDetails为零吗?

Well, when you write loanDetails.currency = myCurrency , that's the equivalent of calling [loanDetails setCurrency:myCurrency] . 好吧,当您编写loanDetails.currency = myCurrency ,这等效于调用[loanDetails setCurrency:myCurrency] So, take a look at your header: did you define it readonly by accident? 因此,看一下标题:您是否偶然将其定义为readonly Have you synthesized accessor methods or did you write your own? 您是否已合成访问器方法或编写了自己的访问器方法?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM