Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
add Example
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinichiro Oba committed Nov 10, 2015
1 parent 1a70912 commit 8b803f8
Show file tree
Hide file tree
Showing 17 changed files with 622 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "Carthage/Checkouts/Alamofire"]
url = https://github.com/Alamofire/Alamofire.git
[submodule "Carthage/Checkouts/Result"]
path = Carthage/Checkouts/Result
url = https://github.com/antitypical/Result.git
1 change: 0 additions & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
github "antitypical/Result" "0.6.0-beta.6"

1 change: 1 addition & 0 deletions Cartfile.private
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github "Alamofire/Alamofire" ~> 3.0
1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
github "Alamofire/Alamofire" "3.1.2"
github "antitypical/Result" "0.6.0-beta.6"
1 change: 1 addition & 0 deletions Carthage/Checkouts/Alamofire
Submodule Alamofire added at 8b3ffa
46 changes: 46 additions & 0 deletions Example/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// AppDelegate.swift
// iOS Example
//
// Created by Shinichiro Oba on 11/11/15.
// Copyright © 2015 Shinichiro Oba. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

68 changes: 68 additions & 0 deletions Example/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
28 changes: 28 additions & 0 deletions Example/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
98 changes: 98 additions & 0 deletions Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
<capability name="Alignment constraints to the first baseline" minToolsVersion="6.0"/>
<capability name="Alignment constraints with different attributes" minToolsVersion="5.1"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="iOS_Example" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="tjb-AR-LaX">
<rect key="frame" x="20" y="28" width="50" height="30"/>
<animations/>
<constraints>
<constraint firstAttribute="width" constant="50" id="hBb-9O-yLJ"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" keyboardType="numbersAndPunctuation"/>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="-" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jjP-5G-KAp">
<rect key="frame" x="78" y="32" width="8" height="21"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hv9-MT-f6V">
<rect key="frame" x="152" y="28" width="30" height="30"/>
<animations/>
<state key="normal" title="="/>
<connections>
<action selector="didPush:" destination="BYZ-38-t0r" eventType="touchUpInside" id="3UY-Mz-EbF"/>
</connections>
</button>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="BLf-3L-K3j">
<rect key="frame" x="94" y="28" width="50" height="30"/>
<animations/>
<constraints>
<constraint firstAttribute="width" constant="50" id="dCd-rj-doM"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" keyboardType="numbersAndPunctuation"/>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="?" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9cQ-ho-FR3">
<rect key="frame" x="190" y="32" width="37" height="21"/>
<animations/>
<constraints>
<constraint firstAttribute="width" constant="37" id="QPT-Vb-b53"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="9cQ-ho-FR3" firstAttribute="leading" secondItem="hv9-MT-f6V" secondAttribute="trailing" constant="8" symbolic="YES" id="3RI-jA-2we"/>
<constraint firstItem="BLf-3L-K3j" firstAttribute="baseline" secondItem="tjb-AR-LaX" secondAttribute="baseline" id="B6b-gz-pIP"/>
<constraint firstItem="tjb-AR-LaX" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="I1M-Ar-85q"/>
<constraint firstItem="tjb-AR-LaX" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="8" symbolic="YES" id="KQv-df-btd"/>
<constraint firstItem="BLf-3L-K3j" firstAttribute="top" secondItem="hv9-MT-f6V" secondAttribute="top" id="MqY-fc-VUG"/>
<constraint firstItem="9cQ-ho-FR3" firstAttribute="baseline" secondItem="hv9-MT-f6V" secondAttribute="firstBaseline" id="PgV-xg-5kn"/>
<constraint firstItem="jjP-5G-KAp" firstAttribute="centerY" secondItem="tjb-AR-LaX" secondAttribute="centerY" id="SZ1-x1-7ra"/>
<constraint firstItem="BLf-3L-K3j" firstAttribute="leading" secondItem="jjP-5G-KAp" secondAttribute="trailing" constant="8" symbolic="YES" id="Ub8-ro-61u"/>
<constraint firstItem="jjP-5G-KAp" firstAttribute="leading" secondItem="tjb-AR-LaX" secondAttribute="trailing" constant="8" symbolic="YES" id="YLg-Pr-123"/>
<constraint firstItem="9cQ-ho-FR3" firstAttribute="firstBaseline" secondItem="jjP-5G-KAp" secondAttribute="firstBaseline" id="cYt-Zz-2AR"/>
<constraint firstItem="hv9-MT-f6V" firstAttribute="bottom" secondItem="BLf-3L-K3j" secondAttribute="bottom" id="g7X-6F-wio"/>
<constraint firstItem="hv9-MT-f6V" firstAttribute="baseline" secondItem="jjP-5G-KAp" secondAttribute="baseline" id="lgS-Q3-qj9"/>
<constraint firstItem="hv9-MT-f6V" firstAttribute="baseline" secondItem="9cQ-ho-FR3" secondAttribute="baseline" id="qC1-Ra-aQC"/>
<constraint firstItem="hv9-MT-f6V" firstAttribute="leading" secondItem="BLf-3L-K3j" secondAttribute="trailing" constant="8" symbolic="YES" id="sOp-i3-r4Z"/>
<constraint firstItem="BLf-3L-K3j" firstAttribute="bottom" secondItem="tjb-AR-LaX" secondAttribute="bottom" id="zi1-qq-Etq"/>
</constraints>
</view>
<connections>
<outlet property="answerLabel" destination="9cQ-ho-FR3" id="FhK-i2-4Fc"/>
<outlet property="firstTextField" destination="tjb-AR-LaX" id="PJz-QP-yXR"/>
<outlet property="secondTextField" destination="BLf-3L-K3j" id="csb-7Q-6H8"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="549" y="410"/>
</scene>
</scenes>
</document>
47 changes: 47 additions & 0 deletions Example/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
37 changes: 37 additions & 0 deletions Example/MathService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// MathService.swift
// JSONRPCKit
//
// Created by Shinichiro Oba on 11/11/15.
// Copyright © 2015 Shinichiro Oba. All rights reserved.
//

import Foundation
import JSONRPCKit

// https://jsonrpcx.org/AuthX/Cookbook

struct Subtract: AuthRequestType {
typealias Response = Int

let userName: String
let APIKey: String
let minuend: Int
let subtrahend: Int

var method: String {
return "subtract"
}

var params: AnyObject? {
return [self.minuend, self.subtrahend]
}

var auth: String? {
return "\(self.userName)|\(self.APIKey)"
}

func responseFromObject(object: AnyObject) -> Response? {
return object as? Int
}
}
Loading

0 comments on commit 8b803f8

Please sign in to comment.