05 2018 档案
摘要:命令式编程只需要掌握语言的语法(变量+语句),再加上平台的api即可认为完成学习。 函数式编程在上面的基础上要掌握更多的算子使用方法及含义。
阅读全文
摘要:在Objective-C中,苹果并没有提供JSON转模型(模型转JSON)的接口,往往在开中需要添加第三库来处理JSON数据,比如:JsonModel、MJExtension、Mantle、JsonKit等,想了解更多这些库,可以去看一下这篇文章 iOS中JSON解析三方库的比较。 在Swfit中从
阅读全文
摘要:元类型是指所有类型的类型。 元类型只能类型出现在类型标示位; 类型即能作为类型存在,出现在类型标示位; 也能作为变量存在,出现在元类型的变量位。 http://www.swift51.com/swift2.0/chapter3/03_Types.html#type_inheritance_claus
阅读全文
摘要:Declaration typealias AnyClass = AnyObject.Type .Type The metatype of a class, structure, or enumeration type is the name of that type followed by .Ty
阅读全文
摘要:type(of:) Applied to an object: the polymorphic (internal) type of the object, regardless of how a reference is typed. Static/class members are access
阅读全文
摘要:类型与变量中的类型。只要有变量就可能有泛型的存在。 泛型是在确定类型的结构和函数基础上进行的二次抽象。目的是达到高代码可用。 是针对结构和函数中的类型进行的二次抽象。 算法和结构中的类型(可变)待定。 泛型:泛指类型、待定类型、不确定类型。与变量密切相关。 泛型,即“参数化类型”。--参数:自变量
阅读全文
摘要:In swift 3 and above (or !==) Checks if the values are identical (both point to the same memory address). Comparing reference types. Like == in Obj-C
阅读全文
摘要:Swift is a type-safe language. A type safe language encourages you to be clear about the types of values your code can work with. If part of your code
阅读全文
摘要:Typealias Typealias typealias 是用来为已经存在的类型重新定义名字的,通过命名,可以使代码变得更加清晰。使用的语法也很简单,使用typealias 关键字像使用普通的赋值语句一样,可以将某个已经存在的类型赋值为新的名字。比如在计算二维平面上的距离和位置的时候,我们一般使用
阅读全文
摘要:associatedtype关联类型 定义一个协议时,有的时候声明一个或多个关联类型作为协议定义的一部分将会非常有用。关联类型为协议中的某个类型提供了一个占位名(或者说别名),其代表的实际类型在协议被采纳时才会被指定。你可以通过 associatedtype 关键字来指定关联类型。比如使用协议声明更
阅读全文
摘要:I’ve noticed a lot of beginners in RxSwift ask about DisposeBag. DisposeBag isn’t a standard thing in iOS development neither in other Rx’s implementa
阅读全文
摘要:原文: Method Dispatch in Swift作者: Brain King译者: kemchenj 译者注: 之前看了很多关于 Swift 派发机制的内容, 但感觉没有一篇能够彻底讲清楚这件事情, 看完了这篇文章之后我对 Swift 的派发机制才建立起了初步的认知. 正文 一张表总结引用类
阅读全文
摘要:Self相当于oc中的instance 是什么 相信大家都知道self这个关键字的具体作用,它跟OC里的self基本一样。但是对于Self来说...(WTF,这是什么东西) 当你用错Self的时候编译器会这样提示 'Self' is only available in a protocol or a
阅读全文
摘要:Postfix Self Expression A postfix self expression consists of an expression or the name of a type, immediately followed by .self. It has the following
阅读全文
摘要:dynamic Apply this modifier to any member of a class that can be represented by Objective-C. When you mark a member declaration with the dynamic modif
阅读全文
摘要:在上一篇中,我们分析了在RxSwift中的整个订阅流程。在开讲变换操作之前,首先要弄清楚Sink的概念,不清楚的同学可以翻看上一篇的分析。简单的来说,在每一次订阅操作之前都会进行一次Sink对流的操作。如果把Rx中的流当做水,那么Sink就相当于每个水管水龙头的滤网,在出水之前进行最后的加工。 Si
阅读全文
摘要:Observable.of(1, 2, 3) .map { 0 } .subscribe(onNext: { print($0) }) .disposed(by: disposeBag) Map.swift extension ObservableType public func map
阅读全文
摘要:You write an in-out parameter by placing the inout keyword right before a parameter’s type. An in-out parameter has a value that is passed in to the f
阅读全文
摘要:函数式编程由回掉函数指针衍生; 响应式编程基础是关联操作的封装; 链式编程每一次操作的结果返回一个结构体。
阅读全文
摘要:Written by Paul Hudson @twostraws It's very common in iOS to want to create complex objects only when you need them, largely because with limited comp
阅读全文
摘要:'Self' is the type of a protocol/class/struct/enum.And the 'self' is a instance of a class/struct/enum.As for your requirement,maybe you could write l
阅读全文
摘要:Auto Layout压缩阻力及内容吸附讲解 本文为投稿文章,作者:梁炜V 在Auto Layout的使用中,有两个很重要的布局概念:Content Compression Resistance 和 Content Hugging,从字面的翻译我们大概可以分别翻译为:压缩阻力 以及内容吸附。但是光从
阅读全文
摘要:在 Swift 中能够表示 “任意” 这个概念的除了Any 、AnyObject以外,还有一个AnyClass。 Any、AnyObject、AnyClass有什么区别: 1.AnyObject 本身就是一个接口,而且所有的class都隐式的实现了这个接口,这也限制了AnyObject是只适用于Cl
阅读全文
摘要:开启RxSwift之旅——开篇 RxSwift 是 ReactiveX 在 Swift 下的实现。ReactiveX 是一个通过使用可观察序列来组合异步和基于事件的程序的库。 很多地方通常把 ReactiveX 称为 “函数响应式编程” ,其实这是不恰当的。ReactiveX 可以是函数式的,可以是
阅读全文
摘要:extension Reactive where Base: UIButton { /// Reactive wrapper for `TouchUpInside` control event. public var tap: ControlEvent<Void> { return controlE
阅读全文
摘要:简述 最近老大给了个新项目,我打算用Swift写.原来OC用的RAC,换到Swift自然框架也想试试新的,就用了RXSwift,对于这两个框架,我都是会用,但不解其中的原理,正好最近需求没下来,就研究了研究RXSwif,把自己的收获分享一下,文中要有不准确的地方还望大家多多指正~ 关于RXSwift
阅读全文
摘要:前言 我們在 iOS 開發過程中,幾乎無時無刻都要面對異步事件的處理。例如,按鍵點擊、數據保存、、音頻後臺播放、交互動畫展示。這些事件並不具備特定時序性,甚至它們可能同時發生。 雖然 Apple 提供了通知、代理、GCD、閉包等異步機制,但是這些機制缺乏一個統一的抽象表述。另外,這些機制在處理共享的
阅读全文
摘要:RxSwiftライブラリの作り方をご紹介します。一つの記事ですべてを説明するのは非常に厳しいので、まず Observer や Observable といった基本的なコンポーネントとその周辺について、ひとつずつ作っていく流れで説明します。 注意事項 以下の内容を理解しなくても RxSwift は十分使
阅读全文
摘要:Qiita にあげていた記事ですが、ここにもバックアップをとっておきます この記事は、2017/09/15〜17 に早稲田大学 理工学部 西早稲田キャンパスで開催される iOSDC Japan 2017 で行われるセッション「RxSwiftのObservableとは何か」の発表原稿、およびその補足資
阅读全文
摘要:相信在过去的一段时间里,对 RxSwift 多少有过接触或耳闻,或者已经积累了不少实战经验。此文主要针对那些在门口徘徊,想进又拍踩坑的同学。 为什么要学习 RxSwift 当决定做一件事情时,至少要知道为什么。RxSwift 官网举了几个例子,比如可以统一处理 Delegate, KVO, Noti
阅读全文
摘要:The Reactive Extensions (Rx) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operator
阅读全文
摘要:Language Integrated Query (LINQ, pronounced "link") is a Microsoft .NET Framework component that adds native data querying capabilities to .NET langua
阅读全文
摘要:LINQ http://www.cnblogs.com/lifepoem/archive/2011/12/16/2288017.html LINQ是.NET Framework 3.5的新特性,其全称是 Language Integrated Query,即语言集成查询,是指将查询功能和语言结合起来
阅读全文
摘要:Reactive Extensions (Rx) 原来是由微软提出的一个综合了异步和基于事件驱动编程的库包,使用可观察序列和LINQ-style查询操作。 使用Rx, 开发者可以用Observables来表达异步数据流,使用LinQ操作查询异步数据流,使用Schedulers参数化异步数据流中并发。
阅读全文
摘要:This documentation groups information about the various operators and examples of their usage into the following pages: These pages include informatio
阅读全文
摘要:http://reactivex.io The real power comes with the “reactive extensions” (hence “ReactiveX”) — operators that allow you to transform, combine, manipula
阅读全文
摘要:RxSwift 或许我们都听说过,但或许只知道 RxSwift 这个单词,长篇大论关于 RxSwift 的介绍往往使读者迷失在各种概念当中,却不知如何让它大展伸手。或许我们可以换一种姿势,一些应用场景会让我们产生共鸣,解决问题的方式由很多,为什么不找一种最优的呢?RxSwift也许会帮到你。 什么是
阅读全文
摘要:The features of Swift are designed to work together to create a language that is powerful, yet fun to use. Some additional features of Swift include:
阅读全文
摘要:http://reactivex.io The Observer pattern done right ReactiveX is a combination of the best ideas from the Observer pattern, the Iterator pattern, and
阅读全文
摘要:封装、变换与处理 // Represents a push style sequence. public protocol ObservableType : ObservableConvertibleType { func subscribe<O: ObserverType>(_ observer:
阅读全文