Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift Libraryざっくり現状確認 / Swift library overview

horimislime
November 07, 2014

Swift Libraryざっくり現状確認 / Swift library overview

horimislime

November 07, 2014
Tweet

More Decks by horimislime

Other Decks in Technology

Transcript

  1. enum ApiRouter: URLStringConvertible { static let baseURLString = "http://api.example.com" case

    User(String) case Entry(String, Int) var URLString: String { let path: String = { switch self { case .User(let userId): return "/user/\(userId)" case .Entry(let userId, let entryId): return "/user/\(userId)/entry/\(entryId)/" } }() return ApiRouter.baseURLString + path } }
  2. let log = XCGLogger.defaultInstance() @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { log.setup(logLevel: .Debug, showLogLevel: true, showFileNames: true, showLineNumbers: true, writeToFile: nil) log.info("Initialized") return true } ... }
  3. public enum LogLevel: Int, Comparable { case Verbose case Debug

    case Info case Error case Severe case None } public func < (lhs:XCGLogger.LogLevel, rhs:XCGLogger.LogLevel) -> Bool { return lhs.rawValue < rhs.rawValue }
  4. ΍ͬͺ4XJGUͷ&OVNྑ͍ w &OVNΛൺֱՄೳʹ
 ೥ྸɺϨϕϧ౳ͷσʔλͰ
 ࢖͑ͦ͏ w DBTFͷॱ൪ʹ͸஫ҙ
 SBX7BMVF+BWBͷPSEJOBM 
 ҙຯ͕খ͍͞ॱʹྻڍ͢Δ

    w   ͦΕͧΕʹϝιου͕ඞཁ
 ౳Ձԋࢉ͸&RVBUBCMFQSPUPDPM enum Size: Int, Comparable { case Large case Medium case Small } func < (l:Size, r:Size) -> Bool { return l.rawValue < r.rawValue } var flag = Size.Small < Size.Large // => false
  5. public class XCGConsoleLogDestination : XCGLogDestinationProtocol, DebugPrintable { … public func

    processLogDetails(logDetails: XCGLogDetails) { … var fullLogMessage: String = “…” dispatch_async(XCGLogger.logQueue) { print(fullLogMessage) } } }
  6. class UserSpec: QuickSpec { override func spec() { describe("User") {

    it("should exist") { expect(User("horimi")).notTo(nil) } it("should not exist") { expect(User.get("vavavavava")).to(nil) } } } }