随笔分类 - OC
IOS-OC
摘要:IOS self.使用 个人习惯;只需要在属性初始化的时候使用self.属性,其他时候直接使用属性名就行;使用self.是 使retaincount+1,为了确保当前类对此属性具有拥有权@interface CustomClass : UIViewController{ NSString *str}@property (retain, nonatomic) NSString *str;@implementation CustomClass@synthesize str;-(void)viewDidLoad{ //方法一 用alloc必须手动释放一次 self.str = ...
阅读全文
摘要:/* assign retain copy的setter方法的内部实现 assign: //@property float price; - (void)setPrice:(float)price { _price = price; } - (float)price { return _price; } retain: //@property (retain, readwrite, nonatomic) NSStri...
阅读全文
摘要:Student.h 1 #import <Foundation/Foundation.h> 2 3 @interface Student : NSObject 4 { 5 // 实例变量命名 以 _开头,和系统命名规范一致; 6 7 //1:public的实例变量可以用 -> 方式访问; 8 @public 9 NSString *_publicName;10 //2:默认为protected 权限;子类可以继承;11 @protected12 NSString *_protectedName;13 14 //4:@prope...
阅读全文