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

  • Home
  • SEARCH
  • 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 8490559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:09:35+00:00 2026-06-10T22:09:35+00:00

I am trying to get some code in a view working. I have declared

  • 0

I am trying to get some code in a view working. I have declared a delegate and it does not get instantiated, any Idea what I am missing?
I have tried to summarise how I have done this below. I think that the issue is that somewhere, my dataSource delegate needs to be instantiated.

I have a View called graph view and a delegate that is in the viewcontroller GraphViewController.

I know that the method in GraphView is doing something as it calls the AxisDrawing helper class and draws in Axes.

Here is the relevant code

In GraphView.h I set up the protocol and the dataSourceDelegate

@class GraphView;

@protocol GraphViewDataSourceDelegate
- (float)functionOfX:(float)xValue inGraphView:(GraphView *)sender;
@end

@interface GraphView : UIView

@property(nonatomic, weak) IBOutlet id <GraphViewDataSourceDelegate> dataSourceDelegate;

@end

Which I synthesize in GraphView.m

#import "GraphView.h"
#import "AxesDrawer.h"

@implementation GraphView

@synthesize dataSourceDelegate = _dataSourceDelegate;

Also in Graph View I try to use the delegate as follows (pixel is a CGPoint). This routine does run and I can draw to GraphView from here provided I do not try to use my protocol method. i.e. Some of my DrawRect stuff does get drawn which checks out the linking of the UIView to my custom View

pixel.y = [self.dataSourceDelegate functionOfX:pixel.x inGraphView:self];

++++Breakpoint put in here+++++

In GraphViewController I state that I implement the protocol and implement it as follows. The compiler warns me and spots when the implementation is done, turning of the warning. (I am only returning 3.0 at the moment as a test).

@interface  

GraphViewController () <GraphViewDataSourceDelegate>
@property (nonatomic, weak) IBOutlet GraphView *graphView;

@end

…

-(float) functionOfX:(float)xValue inGraphView:(GraphView *)sender{
    NSLog(@"fofx accessed");
    return 3.0;
}

If I look at the GraphView* object just after a breakpoint, it seems to have no instance. What am I missing out.

This is from the trace at the breakpoint

_dataSourceDelegate struct objc_object * 0x0

EDIT: (In addition to @Clays answer below)

It turned out that my connection to the custom view was broke. This meant that the fault lay with the View not talking to the Custom ViewController. The link is made by ctrl dragging from the View Controller button in the Interface builder to the View within the ViewController.

This caused the ViewController to be instantiated and everything then worked fine.

To put it another way.

The link in question was the Outlet. This has to be declared in the ViewController as a property and then linked in IB using ctrl Drag from the ViewController Name-Bar to the View in the Controller.

Provided that you have added the Outlet property correctly, when you do the ctrl drag, your view will appear an option.

The context button popup information on the ViewController button in IB does give a clue.

If you have neglected to put the outlet property into the view controller, the link does appear in the context button popup but it is greyed out, and when you do the link your View is not named.

Once you put the outlet in, the name appears in the menu but not greyed out.

  • 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-10T22:09:38+00:00Added an answer on June 10, 2026 at 10:09 pm

    Make sure you’ve hooked everything up correctly: setting your GraphView’s dataSourceDelegate, and your GraphViewController’s graphView.

    From the trace it looks like you haven’t done that; or you lose the reference somewhere along the way because at some point nothing’s holding on to it.

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

Sidebar

Related Questions

Trying to get comfortable with jQuery and I have encountered some sample code that
I'm trying to get some basic ajax working on rails. I have a comon
I have some pure CSS navigation I'm working on and I'm trying to get
I'm trying to have some Ajax form in the page which is not working
I'm trying to get some RJS code written with prototype and Rails 2.3.11 to
I'm trying to get some HTML to work with my python code. I've got
I am trying to get some form data from POST method. Here's the code
Dealing with some legacy code and in trying to get a poorly designed database
I'm having some problems trying to get the code below to output the data
Im trying to get some auto complete to work. I have this URL i

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.