1. How to define an OC class
@interface Class Name: Parent class name
{
instance variables (not recommended in. h files, written in the extension of. m)
If the subclass is to inherit, it must be written in. h
}
@property
Method
@end
2. Attributes and instance variables
property is a set of getter and setter
3. Initialization method
-(Id/instancetype) initwithxxx
Specifying the initialization method
4. Convenience Builder
Special initialization method for Alloc and Autorelese (easy memory management)
5.Category
Classification, extension class. More than a good existence.
Syntax format
@interface class name (category name)
@end
@implementation class name (category name)
@end
6. One OC Class (Cup)
//
CUP.h
CUP
//
Created by Carl_fang on 15/3/2.
Copyright (c) 2015 Carl_fang. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface Cup:nsobject
@property (nonatomic) float price;
-(Instancetype) Initwithvolume: (Nsinteger) Volume Brand: (NSString *) brand;
+ (CUP *) Cupwithvolume: (Nsinteger) Brand: (NSString *) brand;
-(void) Fillinwater: (Nsinteger) volume;
@end
7. Memory Management
Focus: Reference counting
Autorelese
iOS New Year review