上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 17 下一页
摘要: // // main.swift // LessonSwift01 // // Created by lanouhn on 16/1/25. // Copyright © 2016年 齐彦坤. All rights reserved. // import Foundation // 输出函数 print("Hello, World!") // 单行注释 /... 阅读全文
posted @ 2017-08-21 15:55 路人Q 阅读(674) 评论(0) 推荐(0) 编辑
摘要: /* 计算字符串长度: C: char *stringValue = "abc李"; printf("%tu", strlen(stringValue)); 打印结果6 OC: NSString *stringValue = @"abc李"; NSLog(@"%tu", stringValue.length); 打印结果4, 以UTF16计算 */ ... 阅读全文
posted @ 2017-08-21 15:39 路人Q 阅读(249) 评论(0) 推荐(0) 编辑
摘要: /* Swift和OC字符不一样 1.Swift是用双引号 2.Swift中的字符类型和OC也不一样, OC中的字符占一个字节, 因为它自包含ASCII表中的字符, 而Swift中的字符除了可以存储ASCII表中的字符还可以存储unicode字符 例如中文: OC:char charValue = '韩' Swift: var charValue: Character = "韩... 阅读全文
posted @ 2017-08-21 15:25 路人Q 阅读(258) 评论(0) 推荐(0) 编辑
摘要: /* 字典定义: 键值对 OC: NSDictionary *dict = [NSDictionary dictionaryWithObject:@"hjq" forKey:@"name"]; NSLog(@"%@", dict); NSDictionary *dict = [NSDictionar 阅读全文
posted @ 2017-08-21 14:51 路人Q 阅读(237) 评论(0) 推荐(0) 编辑
摘要: /* while循环 格式:while(循环保持条件){需要执行的语句} OC: int i = 0; int sum = 0; while (i <= 10) { sum = i++; } while (i <= 10) sum = i++; NSLog(@"%d", sum); 如果只有一条指令 阅读全文
posted @ 2017-08-21 14:39 路人Q 阅读(378) 评论(0) 推荐(0) 编辑
摘要: /* if语句基本使用 OC: int age1 = 10; int age2 = 20; int max; max = age2; if (age1 > age2) { max = age1; } NSLog(@"%d", max); if (age1 > age2) { max = age1; 阅读全文
posted @ 2017-08-21 14:21 路人Q 阅读(241) 评论(0) 推荐(0) 编辑
摘要: /* for循环 格式: for (初始化表达式;循环保持条件;循环后表达式) {需要执行的语句} OC: int sum = 0; for (int i = 0; i <= 10; i++) { sum = i++; } NSLog(@"%d", sum); int sum = 0; int i 阅读全文
posted @ 2017-08-21 13:03 路人Q 阅读(278) 评论(0) 推荐(0) 编辑
摘要: /* break: 跳出循环, 无论循环保持条件是否还为真都不会再执行循环 continue: 跳出本次循环, 如果循环保持条件还为真还会继续执行循环 OC: NSArray *arr = @[@1,@3, @5, @7, @8]; for (NSNumber *num in arr) { if ( 阅读全文
posted @ 2017-08-21 12:35 路人Q 阅读(251) 评论(0) 推荐(0) 编辑
摘要: /* 函数: 完成某个特定任务的代码块, 给代码起一个合适的名称, 称为函数名称; 以后需要执行代码块只需要利用函数名称调用即可. 格式: func 函数名称(参数名:参数类型, 参数名:参数类型,...) -> 函数返回值 {函数实现部分} OC: - (void)sayHello { NSLog 阅读全文
posted @ 2017-08-21 11:28 路人Q 阅读(234) 评论(0) 推荐(0) 编辑
摘要: /* 函数类型: 类似于C语言的指向函数的指针 类似于OC语言的block 函数类型是由函数的参数类型和返回值类型组成的 */ // 这两个函数类型为: (Int, Int) -> Int func sum(a: Int, b: Int) -> Int { return a + b } func s 阅读全文
posted @ 2017-08-21 11:17 路人Q 阅读(286) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 17 下一页