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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:23:59+00:00 2026-05-25T12:23:59+00:00

I’m using the MVC model but I cannot get the data needed for the

  • 0

I’m using the MVC model but I cannot get the data needed for the View, I am trying to use a data source since a View should never own its data. Typically, a protocol is used to create a data source.

  • I have a MVC: CalculatorBrain.[hm] – CalculatorViewController.[hm] – (view is .xib)
  • I also have MVC: GraphingView – GraphingViewController – (model is the data I can’t get)

The goal is: when I press a button on the calculator, it draws the function (e.g.: x+5=) that is currently in it’s display. The calculator part takes care of the expression/function, the display, etc while the graphing part should draw. CalculatorViewController should be the GraphingView’s source, but the data always stays null.

This is GraphingView.h with the declaration of the protocol :

@class GraphingView;

@protocol GraphingViewSource
- (float)getDataPoints:(GraphingView *)requestor;
@end

@interface GraphingView : UIView {
    id <GraphingViewSource> source;
}

@property (assign) id <GraphingViewSource> source;

@end

CalculatorViewController.m implements the protocol by implementing the getDataPoints: method. Header of CalculationViewController.h :

@interface CalculatorViewController : UIViewController <GraphingViewSource>

Pressing the button which should set up the data source :

- (IBAction)graphPressed:(UIButton *)sender
{
    GraphingViewController *graphingVC = [[GraphingViewController alloc] init];
    graphingVC.graphingView.source = self;
    [self.navigationController pushViewController:graphingVC animated:YES];
    [graphingVC release];
}

Pressing the button brings up the new view nicely etc, but following line of code only returns null (inside GraphingView.m) :

float result = [self.source getDataPoints:self];

It seems, I cannot access my data source…

  • 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-25T12:24:00+00:00Added an answer on May 25, 2026 at 12:24 pm

    From your comments it seems that graphingView is nil at the time you are trying to set its source.

    If there is a xib for the view controller, you should be doing this:

    GraphingViewController *graphingVC = [[GraphingViewController alloc] initWithNibName:@"GraphingViewController" bundle:nil];
    

    Instead of a plain init.

    This will create and instantiate all of your view objects so they are available to have properties set before you present the view controller.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but

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.