- Introduction to Functional Programming Johannes Weiß - http://kcy.me/1ngiv
- ReactiveCocoa at MobiDevDay Andrew Sardone - http://kcy.me/1nhl3
- The Future Of ReactiveCocoa Justin Spahr-Summers - http://kcy.me/1nhs7
- Enemy of the State Justin Spahr-Summers - http://kcy.me/1njzs
- WWDC 2014 Session 229 - Advanced iOS Application Architecture and Patterns Andy Matuschak - http://kcy.me/1pyva
- Functioning as a Functionalist Andy Matuschak - http://kcy.me/22o45
- Controlling Complexity in Swift Andy Matuschak - http://kcy.me/23sc9
- Functional and reactive programming with Swift Ash Furrow -
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// #!Swift-1.1 | |
import Foundation | |
// MARK: - (1) classes | |
// Solution 1: | |
// - Use classes instead of struct | |
// Issue: Violate the concept of moving model to the value layer | |
// http://realm.io/news/andy-matuschak-controlling-complexity/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context("Send SMS") { | |
// Specify API to Stub | |
let apiSendSMSStub = OHHTTPStubsTestBlock = { request -> Bool in | |
return request.URL!.path == "/api/sendsms" | |
} | |
it("should success") { | |
... | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context("Send SMS") { | |
// Specify API to Stub | |
let apiSendSMSStub = OHHTTPStubsTestBlock = { request -> Bool in | |
return request.URL!.path == "/api/sendsms" | |
} | |
it("should success") { | |
// Result success | |
let successBlock: OHHTTPStubsResponseBlock = { request -> OHHTTPStubsResponse in | |
let success200 = "{\"success\": true}".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Credit { | |
var count: Int { | |
set { | |
// save newValue of credits to somewhere. | |
} | |
get { | |
return // credits value saved. | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Quick | |
import Nimble | |
import OHHTTPStubs | |
import SMSME | |
class SMSAPISpec: QuickSpec { | |
override func spec() { | |
describe("API") { | |
context("Send SMS") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Alamofire | |
enum APIResult { | |
case Success | |
case Fail(NSError) | |
func isSuccess() -> Bool { | |
switch self { | |
case .Success: return true | |
case .Fail: return false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
platform :ios, '8.0' | |
use_frameworks! | |
target 'SMSME' do | |
pod 'Alamofire' | |
end | |
target 'SMSMETests' do | |
pod 'Quick', '~> 0.3.1' ## For Swift 1.2 | |
pod 'Nimble' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Phone class part | |
// Phone.swift | |
import Foundation | |
class Phone { | |
class func validateNumber(number: String) -> Bool { | |
let pattern = "^(08|09)[0-9]{8}$" | |
let regexp = NSRegularExpression(pattern: pattern, options: .CaseInsensitive, error: nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Phone class part | |
// Phone.swift | |
import Foundation | |
class Phone { | |
class func validateNumber(number: String) -> Bool { | |
// begin with 08 or 09 | |
let beginValid = number.hasPrefix("08") || number.hasPrefix("09") | |