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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:56:07+00:00 2026-05-25T17:56:07+00:00

I have a class defined in a an external pair of files, let’s name

  • 0

I have a class defined in a an external pair of files, let’s name them engine.h and engine.m . Also, it was given to me the file “engineListener.h”.
this is how they look:

File engine.h:

@interface coreEngine: NSObject {
   NSString *displaydValue;
   id <coreEngineListener> listener;
}
-(coreEngine*)initWithListener:(id <coreEngineListener>) _listener;
//...

File engine.m

//imports here
@interface coreEngine()
-(Boolean) MyOperation: ... ... (etc)
@end

File engineListener.h

//imports here...
@class coreEngine;
@protocol coreEngineListener <NSObject>
@required
-(void) someVariable:(coreEngine *)source;
@end

Now, in my myController.h I have this:

//... imports and include ...
@interface myController : NSObject
{
    coreEngine *PhysicsEngine;
}

- (IBAction)doSomething:(id)sender;

And in the myController.m this is what I have:

-(id) init
{
    NSAutorelease *pool = [[NSAutoreleasePool alloc] init];
    coreEngine *PhysicsEngine = [[coreEngine alloc] init];

    [PhysicsEngine release];
    [pool drain];
    return self;
}

- (IBAction)doSomething:(id)sender
{
    [PhysicsEngine MyOperation:Something];
}

The thing now is: the code compiles correctly, but the “[PhysicsEngine MyOperation:Something]” is doing nothing. I’m sure I’m instantiating my class wrongly. The NSObject defined in “engine.h engine.m and enginelistener.h” that I have to load was not made by me, and I have no means to modify it.

I’ve tried doing some dummy/random things based on what I’ve seen around on the internet, without knowing 100% what I was doing. I’m not even close to be familiar with ObjectiveC or C/C++, so be gentle with me. I’m totally noob on this subject.
I’m using Xcode 4, and I have also access to XCode 3.2.6

How should I load my class properly?
Any advice is welcome.
Thanks

  • 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-25T17:56:08+00:00Added an answer on May 25, 2026 at 5:56 pm

    Your class’s -init should look something like this:

    - (id)init
    {
        self = [super init];
    
        if (self != nil)
        {
            coreEngine = [[PhysicsEngine alloc] initWithListener:self];    // I assume you don't have a property declared
        }
    
        return self;
    }
    

    This follows a standard design pattern for initializing classes. You actually do the initialization by calling -init on super. Afterwards, if self was initialized properly (as it almost always will be), you create your PhysicsEngine object. Note that your class needs to conform to the PhysicsEngineListener protocol and implement -someVariable:.

    // Declares protocol conformance
    
    @interface MyController : NSObject <PhysicsEngineListener>
    
    // In MyController.m
    
    - (void)someVariable:(PhysicsEngine *)source
    {
        // Do whatever this is supposed to do
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a class Car defined like this in a car.rb file class Car
If I have the core of a class defined in one file as public
I have an external file: path_to_external_file.rb with some class definition: class A some_definitions end
I have a test class declared in a header file and defined in a
I have a class called LocalizedString that is defined in an external library that
I have a class defined as public class viewGroups extends ListActivity Somewhere in the
I have a class defined as: class Obj { public: int width, height; Obj(int
I have a templated class defined (in part) as template <class T> MyClass {
I have the ViewValue class defined as follows: class ViewValue { private Long id;
I have a template class defined like so: template <class T> class Command {

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.