• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Calling an object from a C function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling an object from a C function


  • Subject: Re: Calling an object from a C function
  • From: "Kiel Gillard" <email@hidden>
  • Date: Wed, 20 Aug 2008 09:53:08 +1000

Hi Charlie,
The format is like any normal C function.

int MyStaticCFunction(int someArg) {

    //invoke myMethod and return the int the myMethod returns
    return [objcObject myMethod:someArg];
}

You wrote:

What is the syntax? For example, how do I invoke the method

- (int) myMethod: (int) int;

In object myObject

from within a C (not Objective C) function and make use of the result?


There are no Objective-C functions. Only C functions. There are Objective-C
methods.

In Objective C I would invoke

[myObject myMethod: myInt];

Even better, how do I invoke

- (myObject) myMethod: (myObject *) myObjectArg;

an make use of the result in a C function?


MyObject * MyStaticCFunction(MyObject *myObjectArg) {

    //assuming MyObject is an Objective C instance
    [myObjectArg myMethod:myObjectArg];
    return myObjectArg;
}

Hope this helps,

Kiel
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Calling an object from a C function
  • Next by Date: Re: NSTableColumn not usable with binder of class NSTextValueBinder?
  • Previous by thread: Re: Calling an object from a C function
  • Next by thread: passing an object between views
  • Index(es):
    • Date
    • Thread