EltBase 0.0.3.3

EltBase 0.0.3.3

Maintained by istroot.



 
Depends on:
CocoaLumberjack>= 0
ReachabilitySwift>= 0
SVProgressHUD>= 0
 

EltBase 0.0.3.3

  • By
  • Elliot

0. EltBase

私人 iOS 开发项目框架,用于快速搭建 OC/Swift 项目的开发框架。 EltBase-GithubEltBase-CococPods

提供功能:

  • 基类库
  • 工具库
    • 日志打印
    • 网络状态检测
    • 苹果登录
  • 视图库

1. 类说明

  • 已实现
    • EltLog: 日志打印
    • EltNetwork: 网络请求、状态检测
    • EltSignInApple: 苹果登录
  • 待实现
    • EltLocation: 定位管理

1.1 工具类

EltLog

  1. 处理 DDLog 在 OC 项目下的编译问题:需要在 pch 文件中,实现如下代码,
    // 因为 oc 不支持 swift 的全局函数、变量等,仅支持带 @objc 的方法、变量。
    // 所以 DDLog 在 swift 和 oc 下是两套不同的代码。

    #ifdef __OBJC__
    #import <CocoaLumberjack/CocoaLumberjack.h>

    #ifdef DEBUG
    static const DDLogLevel ddLogLevel = DDLogLevelVerbose; // 配置 debug 模式的日志输出等级
    #else
    static const DDLogLevel ddLogLevel = DDLogLevelWarning; // 配置 release 模式的日志输出等级
    #endif
    #endif

1.2 视图类

2. 第三方库

一些常用的第三方库,自行在新的项目的 podfile 中按需导入

    spec.dependency "Hue"                                       # 颜色
    spec.dependency 'CocoaLumberjack/Swift'                     # 打印日志
    spec.dependency 'DeviceKit'                                 # 设备型号
    spec.dependency 'DefaultsKit'                               # UserDefaults 管理
    spec.dependency 'FileKit'                                   # 文件管理
    spec.dependency 'KeychainAccess'                            # 钥匙串管理
    spec.dependency 'Kingfisher'                                # 图片加载
    spec.dependency 'IQKeyboardManagerSwift'                    # 键盘管理
    spec.dependency 'KeyboardMan'                               # 键盘变化通知
    spec.dependency 'Kanna'                                     # XML/HTML 解析
    spec.dependency 'Moya'                                      # 网络请求
    spec.dependency 'SwiftyJSON'                                # JSON 解析
    spec.dependency 'SwifterSwift'                              # 各种扩展库
    spec.dependency 'SwiftNotificationCenter'                   # 面向协议的通知总中心
    spec.dependency 'Timepiece'                                 # 日期处理
    spec.dependency 'URLNavigator'                              # 页面路由器
    spec.dependency 'ImageScout'                                # 获取 URL 图片的尺寸
    spec.dependency 'ReachabilitySwift'                         # 监听网络状态
    # 依赖库:视图类
    spec.dependency 'QMUIKit'                                   # 腾讯 UI 库
    spec.dependency 'SnapKit'                                   # 界面布局
    spec.dependency 'R.swift'                                   # 安全地使用资源文件如 UIImage, UIFont 等
    spec.dependency 'Parchment'                                 # 分页控制器
    spec.dependency 'FSPagerView'                               # 轮播图
    spec.dependency 'ActiveLabel'                               # 处理 Hashtags(#)、Mentions(@)、Links(url) 格式 Label
    spec.dependency 'BRPickerView'                              # 选择器
    spec.dependency 'MJRefresh'                                 # 下拉刷新
    spec.dependency 'SVProgressHUD'                             # 等待提示
    spec.dependency 'YYText'                                    # 图文混排处理
    spec.dependency 'TABAnimated'                               # 骨架屏
    spec.dependency 'EFQRCode'                                  # 二维码生成
    spec.dependency 'swiftScan'                                 # 二维码识别
    spec.dependency 'ImageViewer'                               # 图片浏览
    spec.dependency 'LDImagePicker'                             # 图片选择器

注释

注释用到的标识符

  • 类、方法、变量等注释
- Parameters:
	- name1:
	- name2:
- Author:
- Authors
- Copyright:
- Version:
- Requires:
- Returns:
- Throws:
- Since:
- Precondition: The object must contain all the information in the world.
- Postcondition: After the algorithm, the object will contain all the information in the universe.
- Invariant:
- Complexity: O(n^n)
- Important:
- Warning: 
- Attention: 
- Note: 
- Remark: 
- Date: 26 Jan, 2016
  • 文件注释
// TODO: 
// MARK: 
// FIXME: 

OC、Swift 混编

OC 项目内仅支持能用 @objc 标示的类型,否则无法访问:

  • Generics:范型
  • Tuples:元组
  • Enumerations defined in Swift:枚举
  • Structures defined in Swift:结构体
  • Top-level functions defined in Swift
  • Global variables defined in Swift: 全局函数无法访问
  • Typealiases defined in Swift:别名
  • Swift-style variadics:如 get 类型的变量、可选类型的变量
  • Nested types:内嵌类型
  • Curried functions:可里化函数

for swift:

  • enum 需为 int 类型,要用 @objc public 再次修饰
  • static function param 若为 enum,要用 @objc public 再次修饰