开发者

XCode 4 - @private

I don't know if it's some setting I accidentally ticked, but tell me how to fix it please:

Whenever I create a new Obj-C class, it automatically looks like:

#import <Foundation/Foundation.h>

@interface MathUtilities : NSObject {
**@private**

}

@end

That line is automatically inserted. It ne开发者_Go百科ver was there before, but something is not adding it. My files also now come with init and dealloc methods. Did something happen? Also, shouldn't it be importing Cocoa instead of Foundation?

This is XCode 4


There is nothing to fix. XCode is creating stubs for you to fill out your code into. It's a time saver, thats all. It should be generating a header and implementation stub file for you, which you can extend like so:

Your header file (MathUtilities.h):

#import <Foundation/Foundation.h>

@interface MathUtilities : NSObject {
@private:
    NSNumber * num;
}

- (void) doSomeWork;
@end

Your implementation file (MathUtilities.m) :

#import "MathUtilities.h"

@implementation MathUtilities

- (id) init {
    self = [super init];
    if(self) {
        // Initialization code here.
    }

    return self;
}

- (void) dealloc {
    [super dealloc];
}

- (void) doSomeWork {
    return;
}

@end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜