Skip to content

Commit

Permalink
Merge pull request #8 from coshx/feat/ios9_support
Browse files Browse the repository at this point in the history
Feat/ios9 support
  • Loading branch information
acadet committed Sep 22, 2015
2 parents 2f6522d + 4a84016 commit 91a8050
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Caravel.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Pod::Spec.new do |s|
# summary should be tweet-length, and the description more in depth.
#

version = "0.3.4"
version = "0.4.0"

s.name = "Caravel"
s.version = version
Expand Down
6 changes: 4 additions & 2 deletions Caravel.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@
A7F1DD891B17D957001E9B94 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0630;
ORGANIZATIONNAME = "Coshx Labs";
TargetAttributes = {
Expand Down Expand Up @@ -304,7 +306,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -346,7 +348,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
4 changes: 4 additions & 0 deletions caravel-test.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@
A7F1DE1B1B18045C001E9B94 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0630;
ORGANIZATIONNAME = "Coshx Labs";
TargetAttributes = {
Expand Down Expand Up @@ -453,6 +455,7 @@
"/Users/acadet/Documents/workspace/swift/caravel/build/Debug-iphoneos",
);
INFOPLIST_FILE = "caravel-test/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -467,6 +470,7 @@
"/Users/acadet/Documents/workspace/swift/caravel/build/Debug-iphoneos",
);
INFOPLIST_FILE = "caravel-test/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand Down
2 changes: 1 addition & 1 deletion caravel/ArgumentParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
internal class ArgumentParser {

internal class func parse(input: String) -> (busName: String, eventName: String, eventData: String?) {
var queryPairs = input.componentsSeparatedByString("&")
let queryPairs = input.componentsSeparatedByString("&")
var outcome: (busName: String, eventName: String, eventData: String?) = (busName: "", eventName: "", eventData: nil)

for p in queryPairs {
Expand Down
6 changes: 3 additions & 3 deletions caravel/Caravel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public class Caravel: NSObject, UIWebViewDelegate {
public func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
if let scheme: String = request.URL?.scheme {
if scheme == "caravel" {
var args = ArgumentParser.parse(request.URL!.query!)
let args = ArgumentParser.parse(request.URL!.query!)

// All buses are notified about that incoming event. Then, they need to investigate first if they
// are potential receivers
Expand All @@ -134,7 +134,7 @@ public class Caravel: NSObject, UIWebViewDelegate {
self._isInitialized = true

for i in self._initializers {
var index = self._onGoingInitializersId
let index = self._onGoingInitializersId

self._onGoingInitializers[index] = i
self._onGoingInitializersId++
Expand Down Expand Up @@ -315,7 +315,7 @@ public class Caravel: NSObject, UIWebViewDelegate {
objc_sync_exit(Caravel._namedBusInitLock)
return bus
} else {
var newBus = Caravel(name: name, webView: webView)
let newBus = Caravel(name: name, webView: webView)
_buses.append(newBus)
objc_sync_exit(Caravel._namedBusInitLock)
return newBus
Expand Down
22 changes: 11 additions & 11 deletions caravel/DataSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ internal class DataSerializer {

switch (type) {
case .Bool:
var b = input as! Bool
let b = input as! Bool
output = b ? "true" : "false"
case .Int:
var i = input as! Int
let i = input as! Int
output = "\(i)"
case .Double:
var d = input as! Double
let d = input as! Double
output = "\(d)"
case .Float:
var f = input as! Float
let f = input as! Float
output = "\(f)"
case .String:
var s = input as! String
Expand All @@ -39,25 +39,25 @@ internal class DataSerializer {
case .Array, .Dictionary:
// Array and Dictionary are serialized to JSON.
// They should wrap only "basic" data (same types than supported ones)
var json = NSJSONSerialization.dataWithJSONObject(input, options: NSJSONWritingOptions(), error: NSErrorPointer())!
var s = NSString(data: json, encoding: NSUTF8StringEncoding)!
let json = try! NSJSONSerialization.dataWithJSONObject(input, options: NSJSONWritingOptions())
let s = NSString(data: json, encoding: NSUTF8StringEncoding)!
output = s as String
}

return output!
}

internal static func deserialize(input: String) -> AnyObject {
if count(input) > 0 {
if input.characters.count > 0 {
if input[0] == "[" || input[0] == "{" { // Array or Dictionary, matching JSON format
var json = input.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!
return NSJSONSerialization.JSONObjectWithData(json, options: NSJSONReadingOptions(), error: NSErrorPointer())!
let json = input.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!
return try! NSJSONSerialization.JSONObjectWithData(json, options: NSJSONReadingOptions())
}

// To investigate if the input is a number (int or double),
// we check if the first char is a digit or no
if let isANumber = input[0].toInt() {
if let i = input.toInt() {
if let isANumber = Int(input[0]) {
if let i = Int(input) {
return i
} else {
return (input as NSString).doubleValue
Expand Down
6 changes: 3 additions & 3 deletions caravel/UIWebViewDelegateMediator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal class UIWebViewDelegateMediator: NSObject, UIWebViewDelegate {
private lazy var _webViewSubscribers: [Int: [UIWebViewDelegate]] = [Int: [UIWebViewDelegate]]()

private func iterateOverDelegates(webView: UIWebView, callback: (UIWebViewDelegate) -> Void) {
var array = UIWebViewDelegateMediator._singleton._webViewSubscribers[webView.hash]!
let array = UIWebViewDelegateMediator._singleton._webViewSubscribers[webView.hash]!

for e in array {
callback(e)
Expand Down Expand Up @@ -53,7 +53,7 @@ internal class UIWebViewDelegateMediator: NSObject, UIWebViewDelegate {
// About methods below:
// All calls use safe unwrapper for those method implementations are optional

func webView(webView: UIWebView, didFailLoadWithError error: NSError) {
func webView(webView: UIWebView, didFailLoadWithError error: NSError?) {
iterateOverDelegates(webView) { e in
e.webView?(webView, didFailLoadWithError: error)
}
Expand All @@ -64,7 +64,7 @@ internal class UIWebViewDelegateMediator: NSObject, UIWebViewDelegate {
// If any subscriber woud like t

iterateOverDelegates(webView) { e in
var b = e.webView?(webView, shouldStartLoadWithRequest: request, navigationType: navigationType)
let b = e.webView?(webView, shouldStartLoadWithRequest: request, navigationType: navigationType)

// If any subscriber would like to run that URL, DO NOT prevent it to do it
shouldLoad = (b == nil) ? shouldLoad : (shouldLoad || b!)
Expand Down
2 changes: 1 addition & 1 deletion caravel/js/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function (grunt) {
'use strict';

var version = '0.3.4';
var version = '0.4.0';

// Project configuration
grunt.initConfig({
Expand Down
2 changes: 1 addition & 1 deletion caravel/js/caravel.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions caravel/utils/StringExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import Foundation

internal extension String {
subscript (i: Int) -> Character {
return self[advance(self.startIndex, i)]
return self[self.startIndex.advancedBy(i)]
}

subscript (i: Int) -> String {
return String(self[i] as Character)
}

subscript (r: Range<Int>) -> String {
return substringWithRange(Range(start: advance(startIndex, r.startIndex), end: advance(startIndex, r.endIndex)))
return substringWithRange(Range(start: startIndex.advancedBy(r.startIndex), end: startIndex.advancedBy(r.endIndex)))
}
}

0 comments on commit 91a8050

Please sign in to comment.