0
点赞
收藏
分享

微信扫一扫

OC之【@class】

如果是继承某个类,就要导入类的头文件
@class

book.h文件:
#import <Foundation/Foundation.h>
Book : NSObject
int price;
@end

文件:
"Book.h"

Book
- (void)dealloc {
NSLog(@"Book被销毁了");

super dealloc];
}
@end

student.h文件:
#import <Foundation/Foundation.h>
Book;
@interface Student : NSObject
Book
}
Book *book;
@end

student.m文件:
#import "Student.h"
"Book.h"
Student

- (void)setBook:(Book
if (_book
_book release];
_book = [book retain];

// [book retain];
// _book = book;
}
}

- (Book
return _book;
}

- (void)dealloc {
// self.book = nil;

// [self setBook:nil];

_book release];
super dealloc];
}
@end

举报

相关推荐

0 条评论