Re: ObjC from C
Re: ObjC from C
- Subject: Re: ObjC from C
- From: Charles Srstka <email@hidden>
- Date: Fri, 14 Dec 2001 02:21:19 -0600
Have you tried doing this? I guess there might be something I'm not
understanding, but for what I know, this should work fine. I did
something kind of similar to this for a while with Pacifist. I
eventually ended up converting the C function to a nice Obj-C method,
but still...
On Friday, December 14, 2001, at 12:32 AM, jgo wrote:
Really, he's telling the truth. Rename the .c file so it
ends with .m. Import the headers for the class you want
to call the methods from. This should work.
You're supplying an answer for something different from the
question asked... or at least the question I have in mind.
Let's say I have a laboriously built, maintained & accumulated
set of C functions; it's been 15 years in the making. Let's
say it is in a single pair of files b.h and b.c
Now, I'm in Cocoa-land, and I've put together part of a program
(in a.h and a.m), and want to make use of the function
SInt16 myWonderfulCFunction(SInt32 d)
inside of a.m
Well, of course, I'd have to include (or could I import?)
b.h but then would it scream when I wrote
- (int) myWonderfulCocoaMethodUsingBool: (BOOL) what
{
int e;
//...
e = f * g;
return (myWonderfulCFunction(e));
}
And then, we should have an example the other way 'round, with
an invocation of an Objective C method from a C function...
if that's workable. Though I see Marcel has written something
to the effect that it is workable... only not written in
decipherable AmerEnglish.
John G. Otto, Eagle Scout, Knight, Cybernetic Praxeologist
Existence, Consciousness, Identity, Life, Liberty, Property, Privacy,
Justice