Re: Calling an object from a C function
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