Skip navigation.
 
mlRe: Static Functions and Variables
FROM : Jean-Daniel Dupas
DATE : Sun Jun 15 20:01:16 2008

Le 15 juin 08 à 17:38, Jason Stephenson a écrit :

> Whoops! Had a brain fart.
>
> In my previous message where I say @interface, I meant to say 
> @implemenation. Sorry for any confusion.
>
> Got too much going on today. I should have just stayed away from 
> email.
>
> --Jason


In Obj-C, the concept of static functions/variables does not exists, 
i.e. it's purely a C concept, you can put it wherever you want, it 
make no difference.

OK, there is in fact a little difference. If you put a static function 
into an implementation block, it's possible to access ivars directy 
even if they are declared private.


@interface Foo : NSObject {
@private
  NSString *ivar;
}
@end

@implementation Foo

static void MyFunction(Foo *aFoo) {
  NSLog(@"%@", aFoo->ivar);
}

@end

Related mailsAuthorDate
mlStatic Functions and Variables Jason Stephenson Jun 15, 17:36
mlRe: Static Functions and Variables Jason Stephenson Jun 15, 17:38
mlRe: Static Functions and Variables Jean-Daniel Dupas Jun 15, 20:01