类的定义:
#import <Foundation/Foundation.h>
@interface Car : NSObject
{
int wheels;
NSString *Brand;
}
- (void)runWithSpeel:(int)speel andDerition:(int)derition;
+ (NSString*) faceCarBrand;
-(instancetype)init;
@end //类的定义,写在Car.h文件中
类的实现:
#import "Car.h"
#import <foundation/foundation.h>
@implementation Car
- (void)runWithSpeel:(int)speel andDerition:(int)derition
{
NSLog(@"speel:%d derition:%d",speel,derition);
}
+ (NSString*) faceCarBrand
{
return @"car";
}
-(instancetype)init
{
if ([super init]) {
wheels=4;
Brand=nil;
}
return self;
}
@end //写在Car.m文件中
时间: 2024-12-19 08:35:23