Re: Inline C functions in Xcode 3
Re: Inline C functions in Xcode 3
- Subject: Re: Inline C functions in Xcode 3
- From: Chris Hanson <email@hidden>
- Date: Sat, 3 Nov 2007 19:23:29 -0700
On Nov 3, 2007, at 5:21 PM, Vincent Coetzee wrote:
This may also be off-topic and maybe I have missed this if it was
covered earlier in the discussion but could someone explain to dumb
little me why it is not possible to mark Objective-C methods as
inline ?
It was not covered earlier, and would be more on-topic for the objc-
language mailing list.
That said, Objective-C explicitly requires dynamic method dispatch,
and all of Cocoa (and Mac OS X) builds atop this foundation. Thus
there can't be such a thing in Objective-C as an "inline method" - it
wouldn't be dispatched to dynamically, and therefore wouldn't be a
method.
You can define inline functions that have access to instance variables
very easily, however:
@interface MyClass : NSObject {
@private
NSString *foo;
}
@end
@implementation MyClass
inline void LogFoo(MyClass *self) {
NSLog(@"foo is %@", self->foo);
}
- (void)doSomething {
LogFoo(self);
}
@end
The LogFoo function will be inlined if possible, and since it's
defined within an @implementation block for a class, has access to the
@protected and @private instance variables of instances of that class.
-- Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden