• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Inline C functions in Xcode 3
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Inline C functions in Xcode 3
      • From: Vincent Coetzee <email@hidden>
References: 
 >Inline C functions in Xcode 3 (From: David Riggle <email@hidden>)
 >Re: Inline C functions in Xcode 3 (From: Nick Zitzmann <email@hidden>)
 >Re: Inline C functions in Xcode 3 (From: Michael Nickerson <email@hidden>)
 >Re: Inline C functions in Xcode 3 (From: Eric Albert <email@hidden>)
 >Re: Inline C functions in Xcode 3 (From: Steve Checkoway <email@hidden>)
 >Re: Inline C functions in Xcode 3 (From: Vincent Coetzee <email@hidden>)

  • Prev by Date: Re: Xcode 3 SCM Preference Pane Documentation
  • Next by Date: Re: Xcode 3 SCM Preference Pane Documentation
  • Previous by thread: Re: Inline C functions in Xcode 3
  • Next by thread: Re: Inline C functions in Xcode 3
  • Index(es):
    • Date
    • Thread