From 3ed73d601661ed14afaca52aaad8aa51f479cc2c Mon Sep 17 00:00:00 2001 From: icyleaf Date: Tue, 14 Jan 2020 15:11:53 +0800 Subject: [PATCH] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LICENSE | 2 +- README.md | 49 +++++++++++++++++++++++++++++++------ Zealot/Classes/Zealot.swift | 10 +++++--- 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/LICENSE b/LICENSE index 0779542..e1c3c82 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020 icyleaf +Copyright (c) 2020-present icyleaf Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 01ad6eb..65b8b4c 100644 --- a/README.md +++ b/README.md @@ -5,19 +5,52 @@ [![License](https://img.shields.io/cocoapods/l/Zealot.svg?style=flat)](https://cocoapods.org/pods/Zealot) [![Platform](https://img.shields.io/cocoapods/p/Zealot.svg?style=flat)](https://cocoapods.org/pods/Zealot) -## Example +## 安装 -To run the example project, clone the repo, and run `pod install` from the Example directory first. +### Cocoapods -## Requirements +使用 [Cocoapods](https://cocoapods.org) 安装 Zealot 需要把它加到 `PodFile`: -## Installation - -Zealot is available through [CocoaPods](https://cocoapods.org). To install -it, simply add the following line to your Podfile: +> 未达到上线标准前暂不上 Cocoapods Specs ```ruby -pod 'Zealot' +pod 'Zealot', :git => 'https://github.com/getzealot/zealot-ios.git', :branch => 'master' +``` + +保存后开始安装: + +```sh +pod install +``` + +## 使用 + +1. 在 AppDelegate 文件t引入 Zealot 框架头: + +```swift +// Swift +import Zealot +``` + +```objective-c +// Objective-C +#import +``` + +2. 接着在上面文件的 `application:didFinishLaunchingWithOptions:` 方法追加启动代码: + +```swift +// Swift +let zealot = Zealot(endpoint: "http://zealot.test", + channelKey: "...") +zealot.checkVersion() +``` + +```objective-c +// Objective-C +Zealot *zealot = [[Zealot alloc] initWithEndpoint:@"http://zealot.test" + channelKey:@"..."]; +[zealot checkVersion]; ``` ## Author diff --git a/Zealot/Classes/Zealot.swift b/Zealot/Classes/Zealot.swift index c4df7db..ef18102 100644 --- a/Zealot/Classes/Zealot.swift +++ b/Zealot/Classes/Zealot.swift @@ -11,9 +11,8 @@ import UIKit public final class Zealot: NSObject { public let defaultEnvironment: String = "default" public var enviroment: String - - private var endpoint: String - private var channelKeys: [String: String] = [:] + public var endpoint: String + public var channelKeys: [String: String] = [:] public init(endpoint: String, channelKey: String) { self.endpoint = endpoint @@ -32,6 +31,11 @@ public final class Zealot: NSObject { // MARK: - Public methods public extension Zealot { + + func setChannelKey(channelKey: String, environment: String) { + self.channelKeys[environment] = channelKey + } + func checkVersion() { let client = try! Client(endpoint: endpoint, channelKey: useChannelKey()) client.checkVersion { (result) in