感触之言
相信大家对于OC的面向对象的开发都已经了然于胸,不必多说.在Swift中的面向协议开发,进一步使代码块之间的耦合性更低,针对于不同的需要,你可以选择性的选择继承或者extension来选择为某一个类新增方法
正文
假设我现在有一个枚举值

我下面为这个枚举值添加的二个属性值


接下来我使用RXSwift进行实现的,我在控制器初始化了二个控件

导入RXswift的podfile中的文件
pod 'RxSwift'
pod 'RxCocoa'
pod 'RxDataSources'

紧接着需要在viewModel定义属性来监听,同时获取输入的值

LoginResult上面已经讲过了,是一个枚举值,增加了二个属性值
在viewModel中的监听者需要初始化

上面全部完成以后,接下来最重要的工作是在控制器绑定和监听属性值并赋值

效果图如下(不能上传短视频,只能上传一张图了)

具体代码地址:代码
如有错误和需要改正的地方,请指出评论,谢谢各位看官
网友评论