Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift/2.2 #27

Merged
merged 8 commits into from
Mar 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
osx_image: xcode7.3
language: objective-c
cache: cocoapods
before_install: gem install cocoapods obcd slather -N

# Use when you don't have third party dependencies
script: xctool -project Pod/Pod.xcodeproj -scheme Tests -sdk iphonesimulator build test GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES clean test
before_install:
- brew update
- if brew outdated | grep -qx xctool; then brew upgrade xctool; fi
- if brew outdated | grep -qx carthage; then brew upgrade carthage; fi
- travis_wait 35 carthage update --platform Mac,iOS

# Use when you have third party dependencies (CocoaPods generates a workspace)
# podfile: Pod/Podfile
# script: xctool -workspace Pod/Pod.xcworkspace -scheme Tests -sdk iphonesimulator build test GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES clean test

after_success: slather
script:
- xcodebuild clean build -project Cache.xcodeproj -scheme "Cache-iOS" -sdk iphonesimulator
- xcodebuild test -project Cache.xcodeproj -scheme "Cache-iOS" -sdk iphonesimulator
- xcodebuild clean build -project Cache.xcodeproj -scheme "Cache-Mac" -sdk macosx
- xcodebuild test -project Cache.xcodeproj -scheme "Cache-Mac" -sdk macosx
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "Quick/Nimble" "v3.0.0"
github "Quick/Quick" "v0.8.0"
github "Quick/Nimble" "v3.2.0"
github "Quick/Quick" "v0.9.1"
4 changes: 2 additions & 2 deletions Source/Mac/HybridCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public class HybridCache: BasicHybridCache {

let notificationCenter = NSNotificationCenter.defaultCenter()

notificationCenter.addObserver(self, selector: "applicationWillTerminate",
notificationCenter.addObserver(self, selector: #selector(HybridCache.applicationWillTerminate),
name: NSApplicationWillTerminateNotification, object: nil)
notificationCenter.addObserver(self, selector: "applicationDidResignActive",
notificationCenter.addObserver(self, selector: #selector(HybridCache.applicationDidResignActive),
name: NSApplicationDidResignActiveNotification, object: nil)
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Shared/DataStructures/Cachable.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

public protocol Cachable {
typealias CacheType
associatedtype CacheType

static func decode(data: NSData) -> CacheType?
func encode() -> NSData?
Expand Down
3 changes: 2 additions & 1 deletion Source/Shared/Library/DefaultCacheConverter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public struct DefaultCacheConverter<T> {
return pointer.move()
}

public func encode(var value: T) throws -> NSData {
public func encode(value: T) throws -> NSData {
var value = value
return withUnsafePointer(&value) { p in
NSData(bytes: p, length: sizeofValue(value))
}
Expand Down
6 changes: 3 additions & 3 deletions Source/iOS/HybridCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public class HybridCache: BasicHybridCache {

let notificationCenter = NSNotificationCenter.defaultCenter()

notificationCenter.addObserver(self, selector: "applicationDidReceiveMemoryWarning",
notificationCenter.addObserver(self, selector: #selector(HybridCache.applicationDidReceiveMemoryWarning),
name: UIApplicationDidReceiveMemoryWarningNotification, object: nil)
notificationCenter.addObserver(self, selector: "applicationWillTerminate",
notificationCenter.addObserver(self, selector: #selector(HybridCache.applicationWillTerminate),
name: UIApplicationWillTerminateNotification, object: nil)
notificationCenter.addObserver(self, selector: "applicationDidEnterBackground",
notificationCenter.addObserver(self, selector: #selector(HybridCache.applicationDidEnterBackground),
name: UIApplicationDidEnterBackgroundNotification, object: nil)
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/iOS/Helpers/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extension User: Cachable {
do {
data = try DefaultCacheConverter<User>().encode(self)
} catch {}

return data
}
}
6 changes: 3 additions & 3 deletions Tests/iOS/Specs/Extensions/String+CacheSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class StringCacheSpec: QuickSpec {
describe(".decode") {
it("decodes from NSData") {
let string = self.name
let data = string.dataUsingEncoding(NSUTF8StringEncoding)!
let data = string!.dataUsingEncoding(NSUTF8StringEncoding)!
let result = String.decode(data)

expect(result).to(equal(string))
Expand All @@ -36,8 +36,8 @@ class StringCacheSpec: QuickSpec {
describe("#encode") {
it("encodes to NSData") {
let string = self.name
let data = string.dataUsingEncoding(NSUTF8StringEncoding)!
let result = string.encode()
let data = string!.dataUsingEncoding(NSUTF8StringEncoding)!
let result = string!.encode()

expect(result).to(equal(data))
}
Expand Down