开发者

XCode 4 - @private

开发者 https://www.devze.com 2023-03-19 12:42 出处:网络
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:

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

精彩评论

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

关注公众号