Firstly, I wrote my customized setter for an NSString* like this:
- (void)setDateString:(NSString *)newDateString {
self.dateString = newDateString;
NSInteger dateNumber = [dateString integerValue];
// this line causes crash
// do something here..blah blah
}
then the program stops due to infinitely many threads which does [XXX setDateString:].
After several useless tries I found this question/answer which tells me
do not use self. inside of custom accessors. access the variable directly,
so I made my code into
- (void)setDateString:(NSString *)newDateString {
//self.dateString = newDateString;
dateString = newDateString;
NSInteger dateNumber = [dateString integerValue];
// do something here..blah blah
}
then everything works like a charm!!
I am a junior developer of some objective languages, and a newbie to Objective-C.
I want to learn in details for this issue, instead of solving problems without understanding the reason.
So please provide me with some materials/website to understand more about this.
BTW, I use ARC.
Thank you all. :)