摘要: // // main.m // Copy基本使用,拷贝的本质:修改其中一个不能影响另外一个。 // 每个oc对象都有copy和mutableCopy方法,前提是必须遵守NSCopying协议实现copyWithZone方法和NSMutableCopying协议实现mutableCopyWithZone方法。 // copy出来的对象是不可变的(NSString,NSArray,NSD... 阅读全文
posted @ 2017-08-27 22:41 无天666 阅读(270) 评论(0) 推荐(0)
摘要: // // main.m // 集合(数组)对象的内存管理(MRC中) // #import #import "Person.h" int main(int argc, const char * argv[]) { @autoreleasepool { // 1. 如果将一个对象添加到一个数组中, 那么数组会对对象进行一个retain ... 阅读全文
posted @ 2017-08-27 22:31 无天666 阅读(257) 评论(0) 推荐(0)
摘要: // main.m // NSFileManager #import int main(int argc, const char * argv[]) { NSFileManager *manager = [NSFileManager defaultManager]; // 1.判断一个文件或者文件夹是否存在 BOOL flag = [manager f... 阅读全文
posted @ 2017-08-27 22:02 无天666 阅读(265) 评论(0) 推荐(0)
摘要: // // main.m // OC中的常用结构体 // #import int main(int argc, const char * argv[]) { // 1.保存坐标的 // NSPoint === CGPoint;别名 CGPoint point = NSMakePoint(10, 20); // 2.保存尺寸的 // ... 阅读全文
posted @ 2017-08-27 21:51 无天666 阅读(276) 评论(0) 推荐(0)
摘要: // // main.m // NSMutableDictionary // NSDictionary不可变,初始化后就不可以修改,NSMutableDictionary可变,初始化后可以改变。 // #import int main(int argc, const char * argv[]) { // 1.创建一个空的字典 NSMutableDictionary... 阅读全文
posted @ 2017-08-27 18:13 无天666 阅读(233) 评论(0) 推荐(0)
摘要: // // main.m // NSDictionary // // #import int main(int argc, const char * argv[]) { // 1.如何创建 NSDictionary *dict1 = [NSDictionary dictionaryWithObject:@"lnj" forKey:@"name"]; NSStr... 阅读全文
posted @ 2017-08-27 18:02 无天666 阅读(243) 评论(0) 推荐(0)
摘要: // // main.m // NSMutableArray ,可变数组 #import int main(int argc, const char * argv[]) { // 创建一个空的数组 NSMutableArray *arrM = [NSMutableArray array]; NSLog(@"%@", arrM); // 如何添... 阅读全文
posted @ 2017-08-27 16:51 无天666 阅读(394) 评论(0) 推荐(0)
摘要: // // main.m // NSArray和NSString之间转换 #import int main(int argc, const char * argv[]) { NSArray *arr = @[@"lnj", @"lmj", @"jjj"]; // 需求: 用-将所有的姓名连接起来生成一个字符串 // 1.定义一个可变字符串保存拼接之后... 阅读全文
posted @ 2017-08-27 16:24 无天666 阅读(186) 评论(0) 推荐(0)
摘要: // Person.h #import @interface Person : NSObject @property (nonatomic, assign) int age; @end // Person.m #import "Person.h" @implementation Person - (NSString *)description { return [N... 阅读全文
posted @ 2017-08-27 16:09 无天666 阅读(284) 评论(0) 推荐(0)
摘要: // // Person.h #import @interface Person : NSObject - (void)say; - (void)sayWithName:(NSString *)name; @end // // Person.m #import "Person.h" @implementation Person -(void)say { NSLog... 阅读全文
posted @ 2017-08-27 15:40 无天666 阅读(252) 评论(0) 推荐(0)
摘要: // // main.m // NSArray是不可变的,一旦初始化完毕,就不能添加和删除了。类似于NSString和NSMutilString。 #import #import "Person.h" int main(int argc, const char * argv[]) { NSArray *arr1 = [[NSArray alloc] init]; //NSAr... 阅读全文
posted @ 2017-08-27 15:39 无天666 阅读(234) 评论(0) 推荐(0)
摘要: // main.m // NSMutableString基本概念,NSString是不可变字符串,NSMutableString是可变字符串。NSMutableString继承NSString,所以NSString得所有方法NSMutableString都是可以用的。 #import int main(int argc, const char * argv[]) { ... 阅读全文
posted @ 2017-08-27 15:04 无天666 阅读(603) 评论(0) 推荐(0)
摘要: // // main.m // 字符串截取 #import int main(int argc, const char * argv[]) { NSString *str = @"小码哥"; /* // NSRange : 位置/长度 // NSRange range = {6, 3}; // NSRange range; // range.... 阅读全文
posted @ 2017-08-27 14:45 无天666 阅读(463) 评论(0) 推荐(0)
摘要: // // main.m // NSString基本概念 // Foundation框架,苹果有80多个框架,Foundation有125个头文件。 #import int main(int argc, const char * argv[]) { //如何创建字符串对象 /* 通过不同的方式创建字符串,字符串对象储存的位置也不一样 >如果是通过... 阅读全文
posted @ 2017-08-27 14:15 无天666 阅读(1499) 评论(0) 推荐(0)
摘要: // // BabyProtocol.h #import @class Baby; @protocol BabyProtocol // 喂婴儿吃东西 - (void)feedFood:(Baby *)baby; // 哄婴儿睡觉 - (void)hongBaby:(Baby *)baby; @end // // Baby.h // day17 #import #impor... 阅读全文
posted @ 2017-08-27 01:28 无天666 阅读(290) 评论(0) 推荐(0)
摘要: // WifeCondition.h #import @protocol WifeCondition // 会做饭 - (void)cooking; // 会洗衣服 - (void)washing; // 有一份好工作 - (void)job; @end // Person.h #import #import "Wife.h" @interface Person : NSO... 阅读全文
posted @ 2017-08-27 01:07 无天666 阅读(339) 评论(0) 推荐(0)
摘要: // // SportProtocol.h // day17 // #import @protocol SportProtocol //NSObject是默认的协议类,每个协议都要继承NSObject基协议。不写也可以。 // 1.协议只能声明方法, 不能声明属性(跟分类一样) //{ // int _age; //} // 方法声明列表 // 2.注意: 如果没有使用... 阅读全文
posted @ 2017-08-27 00:47 无天666 阅读(258) 评论(0) 推荐(0)
摘要: // // SportProtocol.h // day17 #import @protocol SportProtocol // 方法声明列表 - (void)playFootball; - (void)playBasketball; - (void)playBaseball; @end // // Person.h // day17 #import #import "S... 阅读全文
posted @ 2017-08-27 00:42 无天666 阅读(368) 评论(0) 推荐(0)