Skip to content
Open
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
8 changes: 8 additions & 0 deletions PolyglotSample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,13 @@
TargetAttributes = {
B60F87431985F1C200ABB94A = {
CreatedOnToolsVersion = 6.0;
DevelopmentTeam = 77898Z5KPT;
DevelopmentTeamName = "Mark Hamilton";
LastSwiftMigration = 0800;
};
B60F87551985F1C200ABB94A = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0800;
TestTargetID = B60F87431985F1C200ABB94A;
};
};
Expand Down Expand Up @@ -414,6 +418,7 @@
PRODUCT_NAME = PolyglotSample;
SWIFT_OBJC_BRIDGING_HEADER = "PolyglotSample/Polyglot-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -428,6 +433,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = PolyglotSample;
SWIFT_OBJC_BRIDGING_HEADER = "PolyglotSample/Polyglot-Bridging-Header.h";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand All @@ -450,6 +456,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "PolyglotTests/PolyglotTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUNDLE_LOADER)";
};
name = Debug;
Expand All @@ -468,6 +475,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "PolyglotTests/PolyglotTests-Bridging-Header.h";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUNDLE_LOADER)";
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion PolyglotSample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
return true
}
}
4 changes: 2 additions & 2 deletions PolyglotSample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class ViewController: UIViewController {
@IBOutlet weak var inputTextField: UITextField!
@IBOutlet weak var translationLabel: UILabel!

@IBAction func didTapTranslateButton(sender: AnyObject) {
@IBAction func didTapTranslateButton(_ sender: AnyObject) {
guard let text = inputTextField.text else { return }

UIApplication.sharedApplication().networkActivityIndicatorVisible = true
UIApplication.shared().isNetworkActivityIndicatorVisible = true
translator.translate(text) { translation in
if let language = self.translator.fromLanguage?.rawValue {
self.translationLabel.text = "Translated from \(language.capitalizedString): \(translation)"
Expand Down
6 changes: 3 additions & 3 deletions PolyglotTests/PolyglotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ class PolyglotTests: XCTestCase {
}

func testTranslate() {
let expectation = expectationWithDescription("translation done")
let expectation = self.expectation(withDescription: "translation done")

// Stub POST access token
stubRequest("POST", "https://datamarket.accesscontrol.windows.net/v2/OAuth2-13")
.withBody("client_id=myClientId&client_secret=myClientSecret&scope=http://api.microsofttranslator.com&grant_type=client_credentials".dataUsingEncoding(NSUTF8StringEncoding))
.withBody("client_id=myClientId&client_secret=myClientSecret&scope=http://api.microsofttranslator.com&grant_type=client_credentials".dataUsingEncoding(String.Encoding.utf8))
.andReturn(200)
.withHeaders(["Content-Type": "application/json"])
.withBody("{\"access_token\":\"octocatsruleeverythingaroundme\", \"expires_in\":\"600\"}")
Expand All @@ -95,6 +95,6 @@ class PolyglotTests: XCTestCase {
expectation.fulfill()
}

waitForExpectationsWithTimeout(1, handler: nil)
waitForExpectations(withTimeout: 1, handler: nil)
}
}
6 changes: 3 additions & 3 deletions PolyglotTests/StringExtensionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ class StringExtensionTests: XCTestCase {
XCTAssertNil("".language?.rawValue, "Empty strings should return nil.")
}

func AssertEqualOptional<T : Equatable>(@autoclosure optional: () -> T?, @autoclosure _ expected: () -> T, file: String = __FILE__, line: UInt = __LINE__) {
func AssertEqualOptional<T : Equatable>(@autoclosure _ optional: () -> T?, @autoclosure _ expected: () -> T, file: String = #file, line: UInt = #line) {
if let nonOptional = optional() {
if nonOptional != expected() {
self.recordFailureWithDescription("Optional (\(nonOptional)) is not equal to (\(expected()))", inFile: file, atLine: line, expected: true)
self.recordFailure(withDescription: "Optional (\(nonOptional)) is not equal to (\(expected()))", inFile: file, atLine: line, expected: true)
}
}
else {
self.recordFailureWithDescription("Optional value is empty", inFile: file, atLine: line, expected: true)
self.recordFailure(withDescription: "Optional value is empty", inFile: file, atLine: line, expected: true)
}
}

Expand Down