Re: Obj-C language question: C function within @implementation
Re: Obj-C language question: C function within @implementation
- Subject: Re: Obj-C language question: C function within @implementation
- From: Jeff Harrell <email@hidden>
- Date: Thu, 3 Jul 2003 09:10:47 -0500
I've never seen anything quite like that. I can't tell what the intent
is; is that supposed to be a class or an instance function? Since it
casts the argument to an instance pointer, I'm going to assume that
it's supposed to be an instance method.
@implementation MyClass
- (void)Function
{
[progress stopAnimation:self];
}
@end
That should do the same thing, but without the bizarre (to me) style
and terrifying void-pointer-to-instance-pointer cast. I mean, I've
heard of type coercion before, but this is ridiculous. ;-)
(Warning: code written in Mail.app before morning coffee. Code may
cause your computer to erase your home directory, send copies of itself
to everybody in your address book, and post those naughty pictures of
your S/O on geocities.com under the name "Naughty Programmer ISO 4 Wild
Time -- Dereference My Pointer Now!" for all I know.)
On Thursday, July 3, 2003, at 08:44 AM, Sean McBride wrote:
I'm no Obj-C expert, but I found some suspicious code that my Obj-C
newbie coworker wrote. I've reduced it to this example:
#import <Cocoa/Cocoa.h>
int main(int argc, const char *argv[])
{
return NSApplicationMain(argc, argv);
}
@interface MyClass : NSObject
{
IBOutlet NSProgressIndicator* progress;
}
@end
@implementation MyClass
void Function (void* thing)
{
MyClass* uc = (MyClass*)thing;
[uc->progress stopAnimation:uc];
}
@end
Notice that there is a C function within the @implementation block.
This
compiles without error/warning with gcc and CodeWarrior. If I move
this
outside the @implementation block CW gives an error and gcc gives a
warning (progress is protected), both of which make more sense IMHO.
Should this code compile as it is above? Seems to me progress is
protected no matter where Function() is.
Thanks!
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Mac Software Designer +1-514-822-6000
Matrox Electronic Systems Ltd. Montrial, Quibec, Canada
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
--
email@hidden
http://homepage.mac.com/jharrell
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.