Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8080301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:22:25+00:00 2026-06-05T16:22:25+00:00

Firstly, I wrote my customized setter for an NSString* like this: – (void)setDateString:(NSString *)newDateString

  • 0

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. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:22:26+00:00Added an answer on June 5, 2026 at 4:22 pm
    self.dateString = newDateString;
    

    is equivalent to

    [self setDateString:newDateString];
    

    so this will cause infinite recursion because you are calling it inside -setDateString:.

    See also Difference between self.ivar and ivar?.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly, I've got functions like this. void func1(); void func2(); void func3(); Then I
Firstly: I am totally a newbie for this kind of work. I have a
Firstly, I do not have any malicious intent out of this question. I would
Firstly, sorry for my English (I'm from China). By reading this article( how to
Firstly, what is this called? Is this the system's platform? If I want to
Firstly this is not a homework question. I am practicing my knowledge on java.
firstly, i write this code: int X, Y; for (i=0; i<N; i++) { printf(Enter
Firstly, I would like to thank everyone here in advance. I look very forward
Firstly, let me set out what I'd like to do. Assume I have three
Firstly, sorry about the long question... but this is doing my head in. Any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.