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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:54:29+00:00 2026-05-21T06:54:29+00:00

So I am trying to get a callback setup in Objective-C. I am use

  • 0

So I am trying to get a callback setup in Objective-C. I am use to C++ so I keep hitting this stuff the wrong way. I found this answer and have been trying to model my code in the same way.

How to perform Callbacks in Objective-C

However when in my ‘LocationActivated’ function the xCoord and yCoord seem to have the complete wrong values.

delegate.mm

- (void)Initialize {
    [mWorldObj RegisterActivateDelegate: self];
}

-(void) LocationActivated :(float)xCoord :(float)yCoord {

    int a;
    a++;
    pLocation.center = CGPointMake(xCoord, yCoord);
}

delegate.h

-(void) LocationActivated :(float)xCoord :(float)yCoord;

world.h

id mActivateDelegate;

Delegate call in world.mm

        float msgarr[2];
        msgarr[0] = (float)((camera.VideoWidth() * 0.5f) + projX) + curLoc->mPopOffsetX;
        msgarr[1] = (float)((camera.VideoHeight() * 0.5f) - projY) + curLoc->mPopOffsetY;
        if(mActivateDelegate != null) {

            [mActivateDelegate LocationActivated :msgarr[0] :msgarr[1]];
        }

When calling msgarg[0] and [1] are completely valid values, ~(200, 200). But when in the callback the values are now completely different. I dumped the memory on both sides and didn’t see any commonalities so my best guess is I am doing the function call totally wrong.

I also get a warning on the [mActivateDelegate LocationActivated] line saying ‘Location Activated may not repsond’ which makes sense because as far as the compiler knows mActiveDelegate is of type ‘id’.

Any idea what I am doing wrong? Better way to approach this?

Edit:

Adding Register function from delegate.mm

- (void)RegisterActivateDelegate :(id) delegate {

    mActivateDelegate = delegate;
}
  • 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-21T06:54:29+00:00Added an answer on May 21, 2026 at 6:54 am

    You asked for a better way to do it. I typed this directly into the window, so I don’t know if it compiles, but this is how to approach it. Name things using ObjC conventions. This is important and will break things if you don’t. Methods start with a lower-case. Name your parameters.

    World.h

    @protocol WorldDelegate;
    @interface World : NSObject
    @property (nonatomic, readwrite, assign) id<WorldDelegate> delegate;
    @end
    
    @protocol WorldDelegate <NSObject>
    - (void)world:(World*)world didActivateLocation:(CGPoint)aPoint;
    @end
    

    World.mm

    @implementation World
    @synthesize delegate = delegate_;
    
    - (void)dealloc {
        delegate_ = nil;
        [super dealloc];
    }
    
    ...
    
    if ([self delegate] != nil) {
        CGFloat x = ((camera.VideoWidth() * 0.5f) + projX) + curLoc->mPopOffsetX;
        CGFloat y = ((camera.VideoHeight() * 0.5f) - projY) + curLoc->mPopOffsetY;
        [[self delegate] world:self didActivateLocation:CGPointMake(x, y)];
    }
    

    WorldDelegate.h

    #import "World.h"
    @interface WorldDelegate : NSObject <WorldDelegate>
    @property (nonatomic, readwrite, assign) World *world;
    - (id)initWithWorld:(World*)aWorld;
    @end
    

    WordDelegate.mm

    @interface WorldDelegate
    @synthesize world = world_;
    - (id)initWithWorld:(World*)aWorld {
        self = [super init];
        [aWorld setDelegate:self];
        world_ = aWorld;
        return self;
    }
    
    - (void)dealloc {
        [world_ setDelegate:nil];
        world_ = nil;
        [super dealloc];
    }
    
    - (void)world:(World*)aWorld didActivateLocation:(CGPoint)aPoint {
        int a;    // What is all this?
        a++;
        pLocation.center = aPoint;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My simple ActionScript I am trying to use Flash's ExternalInterface to setup a callback
Im trying to get the callback from this: $.getScript( 'http://gdata.youtube.com/feeds/api/videos/<?php echo $m; ?>?v=2&alt=json-in-script', function(data)
I'm trying to get an jquery ajax callback function to update the background colour
While trying to GET a JSON, my callback function is NOT firing. $.ajax({ type:GET,
Trying to get comfortable with jQuery and I have encountered some sample code that
Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
Trying to get my mind around google protobuf. I found some implementation of protobuf
I have a WF service that I'm trying to setup receive activities to Subscribe
Since Node is asynchronous, I'm having problems trying to get a callback to return
I'm trying to get a jsonp callback working using jquery within a greasemonkey script.

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.