随笔分类 -  swift

1 2 3 4 5 ··· 8 下一页
摘要:写在最前 文章标题谈到了面向协议编程(下文简称 POP),是因为前几天阅读了一篇讲 Swift 中 POP 的文章。本文会以此为出发点,聊聊相关的概念,比如接口、mixin、组合模式、多继承等,同时也会借助各种语言中的例子来阐述我的思想。 那些老生常谈的概念,相信每位读者都耳熟能详了,我当然不会无聊 阅读全文
posted @ 2022-05-18 15:37 zzfx 阅读(124) 评论(0) 推荐(0) 编辑
摘要:在继承、组合外添加了新的功能添加(组合)方式 Protocols can have default implementations for requirements specified in a protocol extension, allowing “mixin” or “trait” like 阅读全文
posted @ 2022-05-18 15:17 zzfx 阅读(35) 评论(0) 推荐(0) 编辑
摘要:swift Existential Container witness table 的本质是类型的封装转换 与monand对普通类型的封装没有本质的区别。 T->T' 阅读全文
posted @ 2020-01-04 22:43 zzfx 阅读(290) 评论(0) 推荐(0) 编辑
摘要:func a(en:String) -> String { return en + "a"; } func b(en:String) -> String { return en + "b"; } func c(en:String) -> String { return en + "c"; } fun 阅读全文
posted @ 2019-08-16 19:08 zzfx 阅读(200) 评论(0) 推荐(0) 编辑
摘要:func baseFunc(go:String, goo:String) -> String { return "hello" + go + goo; } func CurryFunc(baseFun:@escaping (String,String)->String) ->(String) -> 阅读全文
posted @ 2019-08-16 18:38 zzfx 阅读(284) 评论(0) 推荐(0) 编辑
摘要:“Unlike stored instance properties, you must always give stored type properties a default value. This is because the type itself does not have an init 阅读全文
posted @ 2019-07-22 14:46 zzfx 阅读(180) 评论(0) 推荐(0) 编辑
摘要:In Swift, however, type properties are written as part of the type’s definition, within the type’s outer curly braces, and each type property is expli 阅读全文
posted @ 2019-07-22 14:44 zzfx 阅读(365) 评论(0) 推荐(0) 编辑
摘要:The foundation of Aspect Oriented Programming is the intercept pattern. We start with a crosscutting requirement - something that needs to occur in ma 阅读全文
posted @ 2019-07-22 14:19 zzfx 阅读(245) 评论(0) 推荐(0) 编辑
摘要:顶级抽象:protocol 具体类型:值类型、引用类型 类型操作:扩展 其他: 范型、函数式类型:function、monand 阅读全文
posted @ 2019-07-22 12:03 zzfx 阅读(246) 评论(0) 推荐(0) 编辑
摘要:swift是对oc的扩展 Swift是没有消息机制的Objective-C https://www.oschina.net/translate/inside-swift; swift保持了oc的类结构形式,对函数的派发机制做了调整。 一、class swift完全继承了oc class类的运行时结构 阅读全文
posted @ 2019-07-22 11:55 zzfx 阅读(601) 评论(0) 推荐(0) 编辑
摘要:类型继承; 类型扩展; 类型组合; 类型变换; 阅读全文
posted @ 2019-06-06 16:36 zzfx 阅读(211) 评论(0) 推荐(0) 编辑
摘要:swift是面向对象、面向协议、高阶类型、灵活扩展、函数式编程语言 阅读全文
posted @ 2019-06-06 16:19 zzfx 阅读(281) 评论(0) 推荐(0) 编辑
摘要:一、具体类型 基本类型: class struct enum 组合类型: Tuples function 容器类型: struct<—— 二、抽象类型: protocol typeclass Generic 阅读全文
posted @ 2019-06-05 16:41 zzfx 阅读(228) 评论(0) 推荐(0) 编辑
摘要:At first glance, Swift looked different as a language compared to Objective-C because of the modern code syntax. Secondly, the strict and strong type 阅读全文
posted @ 2019-06-04 17:22 zzfx 阅读(247) 评论(0) 推荐(0) 编辑
摘要:c++是面向对象的多态语言; oc是面向对象的动态语言; swift是面向对象、面向协议、高阶类型、函数式编程语言; 阅读全文
posted @ 2019-05-30 17:17 zzfx 阅读(321) 评论(0) 推荐(0) 编辑
摘要:前言 在Objective-c的世界中,一切对象都是指针。它是一种运行时语言,具体指针的对象类型将会在运行时,由系统分配。这样虽然自由,但是却并不安全。 Swift世界就不一样了,Swift的世界很安全(至少大部分时候情况如此)。我们不必为对象运行时的类型担忧,这是Swift为我们构筑的一层堡垒。但 阅读全文
posted @ 2019-04-18 15:13 zzfx 阅读(362) 评论(0) 推荐(0) 编辑
摘要:class Human { //8 type or isa //retainCount var age: Int?//16 var name: String?//16 var nicknames: [String] = [String]() //返回指向 Human 实例头部的指针 func hea 阅读全文
posted @ 2019-04-02 16:06 zzfx 阅读(614) 评论(0) 推荐(0) 编辑
摘要:主要目标是提供抽象能力和解决值类型的多态问题 Actually, Abrahams says, those are all attributes of types, and classes are just one way of implementing a type. Yet, they exac 阅读全文
posted @ 2019-03-29 18:24 zzfx 阅读(313) 评论(0) 推荐(0) 编辑
摘要:One can explicitly write @objc on any Swift declaration that can be expressed in Objective-C. @objc相关的参量只能修饰类、类的成员、扩展以及只能被类实现的协议; 下面开列修饰的情况和说明 一、无修饰 N 阅读全文
posted @ 2019-03-26 19:33 zzfx 阅读(1592) 评论(0) 推荐(0) 编辑
摘要:The convention of the function, indicated by the attribute. This is similar to the language-level @convention attribute, though SIL extends the set of 阅读全文
posted @ 2019-03-26 18:06 zzfx 阅读(339) 评论(0) 推荐(0) 编辑

1 2 3 4 5 ··· 8 下一页