06 2015 档案
摘要://应用程序启动后调用的第一个方法 不懂的程序可以做不同的启动//launchOption参数的作业:应用在特定条件下的不同启动参数 比如:挑战的支付宝支付- (BOOL)application:(UIApplication *)application didFinishLaunchingWithO...
阅读全文
摘要:•通过修改控件的frame属性就可以修改控件在屏幕上的位置和尺寸•比如点击“向上”按钮,让按钮的y值减小即可- (IBAction)top:(UIButton *)sender { CGRect btnFrame = self.headBtn.frame; btnFrame.origin.y -= ...
阅读全文
摘要:一个UIColor代表一种颜色,通过UIColor的类方法,可以获得很多常用的颜色+ (UIColor *)blackColor; // 0.0 white 黑色+ (UIColor *)darkGrayColor; // 0.333 white 深灰色+ (UIColor *)lightGrayC...
阅读全文
摘要:- (void)addSubview:(UIView *)view;添加一个子控件view- (void)removeFromSuperview;从父控件中移除- (UIView *)viewWithTag:(NSInteger)tag;根据一个tag标识找出对应的控件(一般都是子控件)UIView...
阅读全文
摘要:@property(nonatomic,readonly) UIView *superview;获得自己的父控件对象@property(nonatomic,readonly,copy) NSArray *subviews;获得自己的所有子控件对象@property(nonatomic) NSInte...
阅读全文
摘要:主要方法和类型Class 变量名 = [类或者对象 class];Class 变量名 = [类或者对象 superclass];Class 变量名 = NSClassFromString(方法名字的字符串);NSString *变量名 = NSStringFromClass(Class 参数);•通...
阅读全文
摘要:对自定义类型的对象进行本地化保存,那么该类型必须实现NSCoding协议!NSCoding 协议中只有两个方法,都是require的方法,一个是把本身的类型进行编码,一个是解码成类对象,返回一个对象。-(void)encodeWithCoder:(NSCoder*)encoder-(id)initW...
阅读全文
摘要:系统类型主要是指NSString NSDictionary,NSArray,NSData,NSNumber 类型数据(包括对应可变类型);这些类型已经实现了NSCoding协议,支持归档,写入方法:writeToFile:atomically:读取方法:-dictionaryWithContents...
阅读全文
摘要:NSFileHandle 类中得到方法可以很方便的对文件数据进行读写、追加,以及偏移量的操作。NSFileHandle 基本步骤:1、打开文件,获取一个NSFileHandle 对象2、对打开NSFileHandle的文件对象进行I/O操作3、关闭文件对象+(NSFileHandle *)fileH...
阅读全文
摘要:+(NSFileManager *)defaultManager;//获得文件管理对象-(BOOL)createFileAtPath:(NSString *)path contents:(NSData *)data attributes:(NSDictionary *)attr;//创建文件-(BO...
阅读全文
摘要:copy 减少对象上下文依赖 copy 创建一个新对象,copy得到的副本对象与原来内容相同,新的对象retain为1,与旧有对象的引用计数无关,旧有对象没有变化使用 copy 创建出来的对象是不可变的, 使用mutableCopy创建出来是可以改变的如果对不可变对象复制,copy是指复制(浅拷贝)...
阅读全文
摘要:assign:默认参数setter 方法不会引起引用计数的变化retain:setter方法首先释放旧的对象,将旧对象的值赋予输入对象,再提高输入对象的引用计数为1copy:setter 方法首先建立了一个相同的对象,先对象引用计数为1旧对象引用计数无变化ARC中strong==retainweak...
阅读全文
摘要:autoreleasepool 池子被销毁的时候被标记 autorelease 的对象调用一次releasePerson *p2=[[[Person alloc]init]autorelease];标记为autoreleaseassign默认参数,setter方法不会引起引用计数的变化retain ...
阅读全文
摘要:NSDate 表达日期表达时间的方法NSDate *now=[NSDate date]; 获得当前日期NSDate *tomrrow=[now dateByAddingTimeInterval:24*60*60];NSComparisonResulte result =[now compare:to...
阅读全文
摘要:NSNumber 是一个数值类型封装起来的数值。装箱:基础类型->对象类型NSNumber *number=[NSNumber numberWithInt:12];拆箱:对象类型->对象类型int a = [num intValue];NSintegerNSValue 是NSNumber 父类 不可...
阅读全文
摘要:无序集合 哈希表NSSet *colors=[NSSet setWithObjects:@@"yellow",@"red",@"blue",@"black",nil];NSArray *array=[colors allObjects];NSString *obj = [colors anyObje...
阅读全文
摘要:存储对象都必须是id(对象类型)不能使基础类型NSDictionary *scores=[[NSDictionary alloc]initWithObjectsAndKeys:@"89",@"english",@"70",@"computer",nil];*scores=[[NSDictionary...
阅读全文
摘要:系统类型排序;NSArray *goodsNames =@[@"computer",@"iphone",@"ipad"];NSArray *sortedArray=[goodsNames sortedArrayUsingSelector:@selector(compare:)];自定义排序Perso...
阅读全文
摘要:块是对c语言的一种扩展语法块看起来像函数,不同的是,快可以直接写在函数内部块能够作为参数传递给函数或者方法void sayHello(){NSLog(@"hello!");}int main(){//定义一个blockint i=1; void(^sayHello)(void)=^{ NSLog...
阅读全文
摘要:Shape *shape=[[Shape alloc]init];//[shape draw]SEL selDraw=@selector(draw);[shape performSelector:selDraw];[shape performSelector:@selector(draw:)with...
阅读全文
摘要:NSArray *fruitArray=[[NSArray alloc] initWithObjects:@"apple",@"banana",@"pear",nil];开辟一个不可变的数组NSString *obj=[fruitArray objectAtIndex:1];NSArray *nam...
阅读全文
摘要:NSString *info=@"Hello world";NSString *info=[[NSString alloc]initWithFormat:@"my name is %@",name];将char 类型的字符串和 NSString 进行转换char *cStr = "i am c st...
阅读全文
摘要:触摸屏幕监听的函数 (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{}取消弹出的键盘 只要释放当前文本框的第一响应者 [self.Outlable resignFirstResponder];for(object *b i...
阅读全文

浙公网安备 33010602011771号