天天看點

[翻譯] TransitionKit

transitionkit

[翻譯] TransitionKit

<a href="https://github.com/blakewatters/transitionkit" target="_blank">https://github.com/blakewatters/transitionkit</a>

[翻譯] TransitionKit

a simple, elegantly designed block based api for implementing state machines in objective-c

一套簡單,優雅的基于block設計的api,用以實作oc中的狀态機.

transitionkit is a small cocoa library that provides an api for implementing a state machine in objective c. it is full-featured, completely documented, and very thoroughly unit tested. state machines are a great way to manage complexity in your application and transitionkit provides you with an elegant api for implementing state machines in your next ios or mac os x application.

transitionkit是一個簡單的cocoa庫,提供api用以實作oc的狀态機.它有着完整的特性,全面的文檔以及經過了詳細的單元測試.狀态機是一個用以解決複雜的ui與資料源業務互動邏輯的一種方案,也許就會用在你的下一款為ios或者os x設計的項目當中.

features

supports an arbitrary number of states and events. 支援任意數目的狀态以及事件

states and events support a thorough set of block based callbacks for responding to state transitions. 狀态與事件支援一系列基于block的回調,用以響應狀态的改變

states, events, and state machines are nscopying and nscoding compliant, enabling easy integration with archiving and copying in your custom classes. 狀态,事件以及狀态機遵循nscopying與nscoding協定,即使你的類中需要支援nscopying,nscoding,你也可以友善的使用狀态機

strongly enforced. the state machine includes numerous runtime checks for misconfigurations, making it easy to debug and trust your state machines. 狀态機非常可靠,可以友善你debug,放行使用

transitions support the inclusion of arbitrary user data via a <code>userinfo</code> dictionary, making it easy to broadcast metadata across callbacks. transitions支援你傳遞字典,你可以友善的将中繼資料進行廣播,通過回調的方式

completely documented. the entire library is marked up with appledoc. 有着完整的文檔,友善你查找

thorougly unit tested. you know it works and can make changes with confidence. 通過了單元測試,請相信,這個狀态機是非常可靠的

lightweight. transitionkit has no dependencies beyond the foundation library and works on ios and mac os x. 輕量級,transitionkit不依賴于foundation架構,你可以便利的在ios于mac os x中使用

installation via cocoapods

推薦的安裝方式是通過cocoapods包來安裝,它提供了靈活的依賴關系,并讓安裝變得非常簡易.建議你通過homebrew,使用cocoapods &gt;= 0.16.0或者是git &gt;= 1.8.0來安裝.

install cocoapods if not already available:

安裝cocoapods,如果你還沒用過cocoapods

change to the directory of your xcode project, and create and edit your podfile and add transitionkit:

進入你的xcode工程目錄,建立,編輯你的podfile,然後添加transitionkit:

install into your project:

安裝到你的項目當中:

open your project in xcode from the .xcworkspace file (not the usual project file)

然後,打開.xcworkspace檔案即可

examples

the following example is a simple state machine that models the state of a message in an inbox.

以下示例是一個簡單的使用示例,用以反映狀态機的基本運作.

unit tests

install the dependencies via cocoapods: <code>pod install 先通過cocoapods來安裝依賴</code>

open the workspace: <code>open transitionkit.xcworkspace 然後打開transitionkit.xcworkspace</code>

run the specs via the product menu &gt; test 然後選擇product menu &gt; test 來運作

contact

blake watters

<a href="http://github.com/blakewatters">http://github.com/blakewatters</a>

<a href="http://twitter.com/blakewatters">http://twitter.com/blakewatters</a>

<a href="mailto:[email protected]">[email protected]</a>

license

transitionkit is available under the apache 2 license. see the license file for more info.

transitionkit支援apache 2 協定,請檢視apache 2 協定了解更多.