Re: ObjC from C
Re: ObjC from C
- Subject: Re: ObjC from C
- From: "R. Eranki" <email@hidden>
- Date: Thu, 13 Dec 2001 15:21:07 -0500
Well, self is something which will only work within methods because it
refers to the instance of a class...
If I'm reading you correctly, you're trying to do something like this:
---------------
- (void)doSomething
{
// ...
}
Bool cFunction(char *foo)
{
[self doSomething];
}
int main(int argc, char **argv)
{
return cFunction("foo");
}
---------------
That will NOT work. You need to start defining some classes, or use
pre-built ones (not using 'self').
Exactly -what- are you attempting to do?
On 12/13/01 10:19 AM, "Rosyna" <email@hidden> wrote:
>
Hmm, it'll let me do it that directly? When Ever I tried it before,
>
I'd always get lots of errors, like "self not defined" then I cried
>
for 2 days and saw a psychiatrist about it.
>
>
Ack, at 12/13/01, Charles Srstka said:
>
>
> 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.
>
>
>
> On Thursday, December 13, 2001, at 12:56 AM, Rosyna wrote:
>
>
>
>> That's the thing, it has to start out as straight C. How can I call
>
>> a Objective C class? What code example?
>
>>
>
>> Ack, at 12/13/01, Erik M. Buck said:
>
>>
>
>>> Of course.
>
>>>
>
>>> Implement SomeLameCFunction(char * bob) in a *.m file or use the compiler
>
>>> option to force it to use Objective-C when compiling that module.
>
>>> Why would anyone doubt this ? This is exactly what Apple's own code
>
>>> example
>
>>> do. What else could the phrase "Super-set of ANSI C" mean ?