1、类的定义:在Xcode中添加文件,选择Cocoa Class 或者Cocoa Touch Class输入类名Person,并选择父类为NSObject默认生成如下两个文件Person.h//// Person.h// ClassAndObject//// Created by Kenshi...
分类:
其他好文 时间:
2015-08-14 13:27:07
阅读次数:
117
#import
@interface calculator :
NSObject
//@property double number;
+(void)texe;
+(void)add:(float)num1 andnum2:(float)num;
+(void)subtract:(float)num1 andnum2:(float)num...
分类:
其他好文 时间:
2015-08-13 23:41:18
阅读次数:
170
内存管理:
1.作用范围:
任何继承了NSObject的对象,堆基本数据类型无效如:int
a ,float price;;等
2.原理:
每个对象内部都保存了一个与之相关的整数,称为引用计数器,
当使用alloc
new
copy创建一个对象的时候,对象的引用计数器被设置为1
每给对象发送一次retain消息,可以使引用计数器+1;
给对象发送一条rele...
分类:
其他好文 时间:
2015-08-13 22:13:32
阅读次数:
107
首先,我们得新建一个遵守MKAnnotation的对象,并且拥有以下几个属性: @interface LHAnnotation : NSObject<MKAnnotation> // Center latitude and longitude of the annotion view. // The impleme...
分类:
移动开发 时间:
2015-08-13 18:22:45
阅读次数:
229
#import @interface PYPerson : NSObject@property (nonatomic, assign) int age;@property (nonatomic, assign) int height;@property (nonatomic, copy) NSStr...
分类:
其他好文 时间:
2015-08-13 17:15:44
阅读次数:
153
单例的写法,需要用到GCD。如下:在.h中@interface JFSingleton : NSObject@property(nonatomic,copy) NSString *tempStr;///类方法+(JFSingleton *) sharedInstance;@end在.m中,有两种写法...
分类:
移动开发 时间:
2015-08-12 18:38:39
阅读次数:
127
Boss类的声明文件#import @protocol BossDelegate-(void)bookTicket;//预定机票-(void)bookRoom;//预定房间-(void)notify;//开会@end@interface Boss : NSObject@property(nonato...
分类:
其他好文 时间:
2015-08-12 16:16:08
阅读次数:
144
---------- CZFriend.h ----------#import @interface CZFriend : NSObject@property (copy, nonatomic) NSString *icon;@property (copy, nonatomic) NSString ...
分类:
其他好文 时间:
2015-08-12 01:16:53
阅读次数:
110
在ios开发过程中,经常会遇到在服务器端获取完数据通过后台使用多线程方式自动更新UI,通常的做法有两种: 1、使用NSObject类的方法performSelectorInBackground:withObject:来创建一个线程。 具体的代码: [Obj...
分类:
移动开发 时间:
2015-08-11 16:23:50
阅读次数:
133
什么是键值编码?
键值编码(Key-Value-Coding)是指,将表示对象包含的信息的字符串作为键值使用,来间接访问该信息的方式。键值编码提供了非常强大的功能,基本上,只要存在访问器方法,生命属性或实例变量,就可以将其名字指定为字符串来访问。
1、使用KVC
定义一个Student类,继承于NSObject。
.h文件
#import
@interfa...
分类:
其他好文 时间:
2015-08-11 16:15:44
阅读次数:
134