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 7772749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:56:59+00:00 2026-06-01T16:56:59+00:00

In essence, here is my code in a subclass of NSTextFieldCell: – (void)setStringValue:(NSString *)aString

  • 0

In essence, here is my code in a subclass of NSTextFieldCell:

- (void)setStringValue:(NSString *)aString {
    [super setStringValue:aString];
    [self doSomething];
}

- (void)doSomething {
    NSLog(@"%@", [self stringValue]);
}

In essence, I’m trying to get my subclass notified of a change in the string value, and when the value changes, I want the subclass of NSCell to be able to do something with that new value (Using -attributedStringValue would be even better, because I want to cache it for special drawing). The problem is, for some reason, calling -(NSString *)stringValue somehow results in a call to -(void)setStringValue which ends up becoming…

…an infinite loop. Can someone enlighten me on this – and a possible workaround?

  • 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-01T16:57:00+00:00Added an answer on June 1, 2026 at 4:57 pm

    Probably stringValue is doing some lazy initialization. If it detects that it has no stringValue but can derive the value from something else (perhaps attributedStringValue?), then it derives the value, calls [self setStringValue:derivedValue], then returns the value.

    This does make life tricky, though. Try something like this?

    @implementation MyCell ()
    {
        BOOL gettingStringValue;
    }
    @end
    
    - (NSString*)stringValue {
        gettingStringValue = YES;
        NSString* stringValue = [super stringValue];
        gettingStringValue = NO;
        return stringValue; 
    }
    
    - (void)setStringValue:(NSString *)aString {
        [super setStringValue:aString];
        if (!gettingStringValue)
            [self doSomething];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a simple code illustrating the essence of a problem: class test: def
I have in essence the following code: typedef std::function<void ()> fnGlobalChangeEvent; typedef std::vector<fnGlobalChangeEvent> GlobalTriggers;
The code here is a modal view launched from the RootViewController and is to
In essence I'd like to store some rows in a temporary variable for the
In essence: every time I clone items I lose the data() value for those
The essence of the problem is, given a class hierarchy like this: class A
The essence of the ie6 bug (dropdown entries must be truncated via overflow hidden
This question seems to be the essence of several others on this forum. I
My question is related to this link stackoverflow ques In essence repeating the figure
I'm going back over an old project where I added preprocessor functionality to Essence'

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.