随笔分类 -  swift

上一页 1 2 3 4 5 6 ··· 8 下一页
摘要:Metatype Types A concrete or existential metatype in SIL must describe its representation. This can be: @thin, meaning that it requires no storage and 阅读全文
posted @ 2019-03-26 17:59 zzfx 阅读(185) 评论(0) 推荐(0) 编辑
摘要:swift 该死的派发机制 final static oc类型 多态类型 静态类型 动态函数 静态函数 nsobject: 1、缺省不再使用oc的动态派发机制; 2、可以使用nsobject暴露出来的接口函数; 3、其它行为与swift的class一样; 多态类型:class与protocol 静态 阅读全文
posted @ 2019-03-22 19:28 zzfx 阅读(521) 评论(0) 推荐(0) 编辑
摘要:Hard Constraints on Resilience The root of a class hierarchy must remain stable, at pain of invalidating the metaclass hierarchy. Note that a Swift cl 阅读全文
posted @ 2019-03-21 19:01 zzfx 阅读(445) 评论(0) 推荐(0) 编辑
摘要:一、测试代码 class BaseCallClass{ func NormalCall(){} @objc func OcCall(){} @objc dynamic func OcDynamicCall(){} } class DerivedCallClass:BaseCallClass{ ove 阅读全文
posted @ 2019-03-20 16:51 zzfx 阅读(445) 评论(0) 推荐(0) 编辑
摘要:class NSObjectBase: NSObject { func Msg_Normal(){ } func Msg_Second(){} func Msg_Third(){} @objc func Msg_ObjcX(){} @objc dynamic func Msg_Objc_Dynami 阅读全文
posted @ 2019-03-20 14:57 zzfx 阅读(342) 评论(0) 推荐(0) 编辑
摘要:swift class的虚函数表、扩展、@objc修饰的研究 工具: swiftc -emit-sil BaseClass.swift | xcrun swift-demangle > ClassFunc.silgen cat ClassFunc.silgen 目标: 1、@objc和@objc d 阅读全文
posted @ 2019-03-19 19:34 zzfx 阅读(1050) 评论(0) 推荐(0) 编辑
摘要:FFI stands for Foreign Function Interface. A foreign function interface is the popular name for the interface that allows code written in one language 阅读全文
posted @ 2019-03-19 16:49 zzfx 阅读(278) 评论(0) 推荐(0) 编辑
摘要:具有接口类型和泛型双重属性;是接口化的高阶泛型; 具有关联类型的协议不能作为类型,只能作为类型约束使用; 类型的具体形态:变量的类型、函数的输入输出类型、容器元素的类型; 带有关联类型的协议作为类型只能和泛型类型一起使用;要使用带有关联类型的协议,必须先定义泛型类型; 在泛化为构造器类型时,作为ty 阅读全文
posted @ 2019-03-15 19:36 zzfx 阅读(412) 评论(0) 推荐(0) 编辑
摘要:swift是强类型语言 强类型:变量的类型明确,变量的赋值必须符合类型约束;变量的类型转化必须显式进行。 强类型:类型规则的制定与检查; 动态类型:变量的具体类型由值类型确定,它的行为也由值类型确定; 动态类型、静态类型:强调类型的绑定; 相对于oc的kindof,允许类型的继承转换; 所有的类型转 阅读全文
posted @ 2019-03-15 15:19 zzfx 阅读(728) 评论(0) 推荐(0) 编辑
摘要:协议多态: 函数式编程多态:高阶函数的多态性; 泛型多态:泛型的基于约束编程; 共同点:相同的接口,不同的行为; 阅读全文
posted @ 2019-03-14 18:27 zzfx 阅读(521) 评论(0) 推荐(0) 编辑
摘要:swift面向协议编程的根本原因在于值类型的存在;面向对象必须要有引用类型的支持; Protocol Oriented approach was introduced to resolve some issues in programming and it also differs in vario 阅读全文
posted @ 2019-03-13 19:32 zzfx 阅读(329) 评论(0) 推荐(0) 编辑
摘要:所谓swift的类型擦除是指: moand转换; 通过技术手段(通常是包装器),将具体类型的类型信息擦除掉了,只将类型的(某一个侧面的)抽象信息(通常指的是类型尊从的协议、接口、或基类)暴露出来。 AnyHashable 属于无关联类型的擦除。 将具体类型的类型信息擦除掉了,只将协议类型的信息暴露出 阅读全文
posted @ 2019-03-13 18:31 zzfx 阅读(354) 评论(0) 推荐(0) 编辑
摘要:AnyHashable 属于无关联类型的擦除。 将具体类型的类型信息擦除掉了,只剩下协议类型的信息暴露出来。 类型擦除实践:将相同协议的不同实现屏蔽起来,暴露出类型的共同特征(协议接口)。 A type-erased hashable value. public struct AnyHashable 阅读全文
posted @ 2019-03-13 18:13 zzfx 阅读(761) 评论(0) 推荐(0) 编辑
摘要:swift语言的特征: 类型系统:值类型与引用类型、泛型、协议类型 函数式编程: 阅读全文
posted @ 2019-03-13 18:10 zzfx 阅读(279) 评论(0) 推荐(0) 编辑
摘要:Type Erasure Pattern We can use the type erasure pattern to combine both generic type parameters and associated types to satisfy both the compiler and 阅读全文
posted @ 2019-03-13 17:28 zzfx 阅读(265) 评论(0) 推荐(0) 编辑
摘要:关键词: 类型与功能绑定、类型指定、访问控制。 类型约束的本质: 1、是否强制指定具有某些特征的类型;看类型构造器的定义本身是否对类型有约束; 2、访问控制:类型构造器的功能分为通用功能和约束功能; 通用功能任何实例类型都能访问; 约束功能,只有符合约束的构造实例能够访问。 类型与算法(功能)绑定; 阅读全文
posted @ 2019-03-13 15:22 zzfx 阅读(455) 评论(0) 推荐(0) 编辑
摘要:三个关注点:1、形式;2、实现方式;3、使用方式; 一、基本形式: 形式:内部无泛型类型; 实现:只需指定类型和实现相应的功能即可; 使用:可以用在其他类型出现的任何地方; protocol Response { /// The task metrics containing the request 阅读全文
posted @ 2019-03-11 18:51 zzfx 阅读(2124) 评论(0) 推荐(0) 编辑
摘要:https://blog.nswebfrog.com/2017/10/20/swift-practice-ui-chaining-code/ 阅读全文
posted @ 2019-03-10 22:03 zzfx 阅读(273) 评论(0) 推荐(0) 编辑
摘要:类型推断的前提是有待定类型和上下文。 1、由定义推断实现的类型; 2、由赋值推断声明的类型; 3、由实现推断泛型的类型; Type inference refers to the automatic detection of the data type of an expression in a p 阅读全文
posted @ 2019-03-10 21:57 zzfx 阅读(456) 评论(0) 推荐(0) 编辑
摘要:为什么说swift是面向协议编程 public protocol ReactiveCompatible { /// Extended type associatedtype CompatibleType /// Reactive extensions. static var rx: Reactive 阅读全文
posted @ 2019-03-08 19:39 zzfx 阅读(917) 评论(0) 推荐(0) 编辑

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