Re: Using C?
Re: Using C?
- Subject: Re: Using C?
- From: "John C. Randolph" <email@hidden>
- Date: Thu, 14 Jun 2001 09:11:03 -0700
On Wednesday, June 13, 2001, at 02:10 PM, <email@hidden>
wrote:
How much C can one use in an Objective-C program and what are the
limitations? I've included a straight C based method in an app I'm
writing -- side by side with my Objective C methods -- and it seems to
work without too many problems.
The only real problem I've experienced with my C method is that it seems
unable to call methods of access variables in the same object. Calling
stuff like [self: doSomething] within the C method results in the
warning
"self undeclared." Is it not possible to mix up C and Objective-C like
this? Also, for example, any variables declared in the header file for
the object are also inaccessable in the C function/method.
Perhaps this all common knowledge! I hadn't previously tried to mix
any C
stuff like this into a Cocoa based app and just sort of dove in head
first. The results have been mixed! =)
First thing: there's no such thing as a "C method." You have
Objective-C Methods, and c Functions.
The reason that you're getting "self undeclared" in your function, is
because self is undeclared!
Methods get two magic parameters which you don't have to declare, "self"
and "_cmd". Functions only get the parameters that you declare. This
isn't like C++, where you can have such a thing as a "member function."
-jcr
"The right to be heard does not include the right to be taken
seriously." - Hubert Humphrey