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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:08:49+00:00 2026-05-30T13:08:49+00:00

For some reason the custom setter of a property never gets called. So it

  • 0

For some reason the custom setter of a property never gets called. So it is always coming through as nil at runtime.

I have a view controller that creates an NSArray of NSValue objects and passes it to the view as a property. However, the property always comes through as nil, even when I verify using the debugger that the NSArray in the view controller is just fine.

View Controller
@interface GraphingViewController()
@property (nonatomic, weak) IBOutlet GraphingView *graphingView;
@end

- (void) determinePointsOnGraph
{
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    NSMutableArray *pointsForGraph = [[NSMutableArray alloc] init];

    float startingPoint = -250;
    for (int i = 0; i < 500; i++) {
        float x = startingPoint;
        startingPoint++;

       [dict setValue:[NSNumber numberWithFloat:x] forKey:[NSString stringWithString:@"x"]];
       float y = [CalculatorBrain runProgram:[self graph] usingVariableValues:dict];

       [pointsForGraph addObject:[NSValue valueWithCGPoint:CGPointMake(x,y)]];
}

//This calls the pointer to the view, and the setter for the view's property
[self.graphingView setPointsOnGraph:pointsForGraph];
}

View

@synthesize pointsOnGraph = _pointsOnGraph;
- (void)setPointsOnGraph:(NSArray *)pointsOnGraph
{
    //Custom setter for property, never gets called if a break point is put here
    _pointsOnGraph = pointsOnGraph;
    [self setNeedsDisplay];
}

- (void)drawLine:(NSArray *)pointsOfLine inContext:(CGContextRef)context
{    
    CGPoint pointsOfLineAsCGPoints[[pointsOfLine count]];

    for (int i = 0; i < sizeof(pointsOfLineAsCGPoints); i++) {
       pointsOfLineAsCGPoints[i] = [[pointsOfLine objectAtIndex:i] CGPointValue];
    }

    CGContextAddLines(context, pointsOfLineAsCGPoints, sizeof(pointsOfLine));
    CGContextClosePath(context);
    CGContextStrokePath(context);
}

The drawLine method is called by the drawRect and is passed the pointsOnGraph property as pointsOfLine. Even if I put a break point in the drawRect and look at the pointsOnGraph property it’s always nil in the view. However, when it is passed to the view by the view controller it contains hundreds of objects.

I just don’t understand why the property is always nil, and if I put a break point in the setter it never gets called.

Update
I have verified that the faceView reference to the view is nil when it is first called, but the IBOutlet appears to be hooked up properly, and the view eventually gets display. It seems that the view controller method is getting called before the self.graphingView IBOutlet is initialized

The Following is from the View Controller that I segue from

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if([segue.identifier isEqualToString:@"Graphing"] ) {
        [segue.destinationViewController setGraph:[[self.brain program] mutableCopy]]; 
        [segue.destinationViewController determinePointsOnGraph];

    }
}

Solution
Call the determinePointsOnGraph method in the viewDidLoad delegate rather than in prepare for segue. This ensures that the view has been created. I also had another problem stemming from the fact that the outlet from the view to access the data in the view controller wasn’t initialized in the view setter.

  • 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-05-30T13:08:51+00:00Added an answer on May 30, 2026 at 1:08 pm

    Call determine points on graph in view delegate method viewDidLoad

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

Sidebar

Related Questions

I have made a custom loop in WordPress and for some reason, the date
I have a view that I am presenting modally. For some reason it animates
I'm trying to build a custom framework but for some reason, there is never
For some reason I'm having issues Binding a custom User Control up through my
I have a tableView with custom tableViewCells that are 42 high. For some reason
For some reason I need to cast/convert a DateTime into one of many custom
For some reason I never see this done. Is there a reason why not?
For some reason the Windows command prompt is special in that you have to
I have a UITableView with some custom cells in it. In these custom cells
For some reason my custom variables are not showing up in my Google Analytics

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.