代码改变世界

随笔分类 -  Object-c

IOS学习之路七(使用 Operation 异步运行任务)

2013-08-09 17:17 by Lves Li, 195 阅读, 收藏,
摘要: 在 application delegate头文件(.h)中声明一个operation队列和两个 invocation operations:#import @interface Running_Tasks_Asynchronously_with_OperationsAppDelegate : UIResponder @property (nonatomic, strong) UIWindow *window; @property (nonatomic, strong) NSOperationQueue *operationQueue; @property (nonatomic, stro.. 阅读全文

IOS基础开发一(ios程序运行过程)

2013-07-27 17:44 by Lves Li, 192 阅读, 收藏,
摘要: 今天做了一个简单的仿QQ登陆UI晒一晒: 阅读全文

Object-c学习之路十二(OC的copy)

2013-07-27 14:20 by Lves Li, 201 阅读, 收藏,
摘要: oc中的拷贝分为:copy(浅拷贝)和mutablecopy(深拷贝)。浅拷贝也为指针拷贝,拷贝后原来的对象计数器会+1;深拷贝为对象拷贝,原来的对象计数器不变。注意:自定义对象拷贝时要实现NSCoping协议或NSMutableCopying协议.且构造方法和copyWithZone方法中最好用[self class]来代替类名下面以NSString的拷贝 和Student,DoodStudent的copy(实现NSCoping协议)为例展示:OC学习基本快告一段落了,终于可以见到IOS界面了呵呵呵呵。。。。。闲话少说直接上代码:主函数:// // main.m // Copy // /.. 阅读全文

Object-c学习之路十一(NSDate和反射)

2013-07-26 16:56 by Lves Li, 152 阅读, 收藏,
摘要: 挺简单啥也不说了直接上代码(NSDate和反射)// // main.m // NSNumberAndNSValue // // Created by WildCat on 13-7-26. // Copyright (c) 2013年 wildcat. All rights reserved. // #import #import "Person.h" #pragma mark -NSDate的练习 void date(){ //获得的当前时间是格林治时间 NSDate *mydate=[NSDate date]; NSLog(@"当前时间是:%@", 阅读全文

Object-c学习之路十(NSNumber&NSValue)

2013-07-26 15:24 by Lves Li, 165 阅读, 收藏,
摘要: // // main.m // NSNumberAndNSValue // // Created by WildCat on 13-7-26. // Copyright (c) 2013年 wildcat. All rights reserved. // #import #pragma mark 对基本数据类型进行包装 void number(){ NSNumber *number=[NSNumber numberWithInt:6]; NSLog(@"%@",number); NSArray *array=[NSArray arrayWithObject... 阅读全文

Object-c学习之路九(字典(NSDictionary&NSMutableDictionary))

2013-07-26 06:09 by Lves Li, 195 阅读, 收藏,
摘要: 字典的练习和使用(遍历,搜索。。。)(Student和Book类文件可以查看上篇博客这次不上传了。)// // main.m // NSDictionary // // Created by WildCat on 13-7-26. // Copyright (c) 2013年 wildcat. All rights reserved. // #pragma mark - NSDictionary练习 #import #import "Student.h" #pragma mark 创建字典 void dictCreat(){ //第一种方式 NSDiction... 阅读全文

Object-c学习之路八(NSArray(数组)遍历和排序)

2013-07-25 19:40 by Lves Li, 311 阅读, 收藏,
摘要: 今天学习了NSArray的遍历和排序,现在在这里做一下总结:遍历现在实现了四中方法:排序大概有三中方法:(代码中都有注释)关于对象的排序还是以Student和Book为例 每个Student持有一个Book.主函数:// // main.m // NSArray // // Created by WildCat on 13-7-25. // Copyright (c) 2013年 wildcat. All rights reserved. // #import #import "Student.h" #pragma mark 创建一个集合 void arrayTest(){ 阅读全文

Object-c学习之路七(oc字符串操作)

2013-07-25 14:22 by Lves Li, 209 阅读, 收藏,
摘要: // // main.m // NSString // // Created by WildCat on 13-7-25. // Copyright (c) 2013年 wildcat. All rights reserved. // #import #pragma mark 创建字符串 void testCreat(){ NSString *str=@"你好。"; NSLog(@"str :%@",str); NSString *str2=[NSString stringWithUTF8String:"哈哈哈"]; NSLog(@& 阅读全文

Object-c学习之路六(oc字符串文件读写)

2013-07-25 11:28 by Lves Li, 275 阅读, 收藏,
摘要: // // main.m // NSString // // Created by WildCat on 13-7-25. // Copyright (c) 2013年 wildcat. All rights reserved. // #import void testCreat(){ NSString *str=@"你好。"; NSLog(@"str :%@",str); NSString *str2=[NSString stringWithUTF8String:"哈哈哈"]; NSLog(@"str2 :%@" 阅读全文

Object-c学习之路五(@protocol协议)

2013-07-24 16:56 by Lves Li, 182 阅读, 收藏,
摘要: 今天模拟Button的delegate来联系一下protocol。Button类// Button.h // Protocal // // Created by WildCat on 13-7-24. // Copyright (c) 2013年 wildcat. All rights reserved. // #import @class Button; //定义一个协议 @protocol ButtonDelegate -(void)onclick:(Button *) button; @end //定义一个类 如果要作为Button的代理一定要实现ButtonDelegat... 阅读全文

Object-c学习之路四(oc内存管理autorelease)

2013-07-24 12:00 by Lves Li, 223 阅读, 收藏,
摘要: 再以Student和Book为例作为展示:1.主函数:// main.m // MemoryManagement2 // // Created by WildCat on 13-7-24. // Copyright (c) 2013年 wildcat. All rights reserved. // #import #import "Book.h" #import "Student.h" int main(int argc, const char * argv[]) { @autoreleasepool { Student *stu=[[[Student 阅读全文

Object-c学习之路三(@class与#import的区别)

2013-07-24 09:57 by Lves Li, 182 阅读, 收藏,
摘要: //@class只是为了声明B是一个类当两个类相互包含的时候#import是做不到的//一般在.h文件中用@class声明一个类成员在..m文件中具体用到时才用#import应用//二者区别: @class只是为了声明一个类 而#import "" 是完全拷贝代码 ;@class比#import ""效率高。//如果是继承某个类一定要用#importa.h// // A.h // MemoryManagement // // Created by WildCat on 13-7-24. // Copyright (c) 2013年 wildcat. Al 阅读全文

Object-c学习之路二(oc内存管理黄金法则1)

2013-07-23 18:28 by Lves Li, 196 阅读, 收藏,
摘要: 今天看了看oc的内存管理,自己管理内存不能随便的release和retain 法则会出现野指针等错误。下面以人和读书的例子做练习。1.主函数// // main.m // MemoryManagement // // Created by WildCat on 13-7-23. // Copyright (c) 2013年 wildcat. All rights reserved. // #import #import "Student.h" #import "Book.h" void test1(){ Student *stu=[[Student al 阅读全文