OC之【@class】
来源:互联网 发布:如何隐藏mac桌面图标 编辑:程序博客网 时间:2024/04/29 18:08
如果是继承某个类,就要导入类的头文件
如果只是定义成员变量、属性,用@class
book.h文件:
#import <Foundation/Foundation.h>
@interface Book : NSObject
@property int price;
@end
book.m文件:
#import "Book.h"
@implementation Book
- (void)dealloc {
NSLog(@"Book被销毁了");
[superdealloc];
}
@end
student.h文件:
#import <Foundation/Foundation.h>
@class Book;
@interface Student :NSObject {
Book *_book;
}
@property Book *book;
@end
student.m文件:
#import "Student.h"
#import "Book.h"
@implementation Student
- (void)setBook:(Book *)book {
if (_book != book) {
[_bookrelease];
_book = [book retain];
// [book retain];
// _book = book;
}
}
- (Book *)book {
return _book;
}
- (void)dealloc {
// self.book = nil;
// [self setBook:nil];
[_bookrelease];
[superdealloc];
}
@end
- OC之【@class】
- OC之@class
- OC学习之路:@class和#import的区别
- OC 基础之--- 多态,内存管理,@class和@ import
- NSString-OC+class
- NSMutableString-OC+class
- NSArray、NSMutableArray-OC+class
- NSDictionary,NSMUtableDictionary-OC+class
- NSSet、NSMutableSet-OC+class
- OC class override
- OC class self
- OC的NSPredicate Class
- oc中的class
- oc中Class是个啥
- OC中的Class类型和class方法
- Create class at OC runtime
- OC中@class的理解
- OC基础—内存管理之@property及其参数(补充新知识:循环引用和@class)
- 更改磁盘号
- 颜色混合opengl
- 更换rootvg硬盘
- 所有浏览器的userAgent为何都带Mozilla
- /usr/bin/ld: cannot find -lxxx问题常见解决办法
- OC之【@class】
- 故障排除
- dmalloc用法快速入门
- 挂载光驱
- 关闭quorum
- 分布式 集群
- 解压文件
- 快速排序时间复杂度分析
- 镜像卷组