discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to call objective-c method from c ?


From: Chris B. Vetter
Subject: Re: How to call objective-c method from c ?
Date: Thu, 16 Oct 2003 10:56:41 -0700

On Thu, 16 Oct 2003 13:42:41 -0400
"Yen-Ju Chen" <address@hidden> wrote:
> How to call objective-c method from c function ?
[...]

Just one way to do it...

  static IMP aMethod;

  @implementation Foo

  - init
  {
    Method_t m;

    self = [super init];

    m = class_getInstanceMethod([Foo class], @selector(method));

    aMethod = m->method_imp;
  
    return self;
  }

  - (bar) method
  {
    [... whatever ...]
  }

  @end

  bar callMethod(id object)
  {
    return aMethod(object, @selector(method));
  }

-- 
Chris




reply via email to

[Prev in Thread] Current Thread [Next in Thread]