简体   繁体   中英

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] . So, take a look at your header: did you define it readonly by accident? Have you synthesized accessor methods or did you write your own?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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