Commit 77c8e0f7 authored by Ignacio Corderi's avatar Ignacio Corderi
Browse files

Added examples

parent 2d2d4583
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@
/* Begin PBXFileReference section */
		382D1C00FC0EC4F1BF676411 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; };
		3E07EA7E1B78E3B500DAB3F1 /* Kinetic.proto.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Kinetic.proto.swift; sourceTree = "<group>"; };
		3E0F7DDD1B7BDD3600F8213F /* Tutorial.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Tutorial.playground; sourceTree = "<group>"; };
		3E0F7DE01B7BDDFF00F8213F /* examples */ = {isa = PBXFileReference; lastKnownFileType = folder; path = examples; sourceTree = "<group>"; };
		3EDAAB3D1B66D32D00F30808 /* Kinetic.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Kinetic.framework; sourceTree = BUILT_PRODUCTS_DIR; };
		3EDAAB401B66D32D00F30808 /* Kinetic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Kinetic.h; sourceTree = "<group>"; };
		3EDAAB421B66D32D00F30808 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -91,7 +91,7 @@
		3EDAAB331B66D32D00F30808 = {
			isa = PBXGroup;
			children = (
				3E0F7DDD1B7BDD3600F8213F /* Tutorial.playground */,
				3E0F7DE01B7BDDFF00F8213F /* examples */,
				3EDAAB3F1B66D32D00F30808 /* Kinetic */,
				3EDAAB4B1B66D32D00F30808 /* KineticTests */,
				3EDAAB3E1B66D32D00F30808 /* Products */,
+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ extension KineticDevice: CustomStringConvertible {
extension KineticSession: CustomStringConvertible {
    public var description: String {
        if self.connected {
            return "Session with \(self.device!)"            
            return "Session \(self.connectionId!) with \(self.device!)"
        } else {
            return "Session not connected"
        }
+0 −25
Original line number Diff line number Diff line
//: Playground - noun: a place where people can play

import Kinetic

let c = Kinetic.connect("localhost", port: 8123)

// commands
let put = PutCommand(key:"nacho", value:"awesome")
try put.sendTo(c)

let get = GetCommand(key:"nacho")
let x = try get.sendTo(c)
String.fromUtf8(x.value!)

// convenience extensions on the channel
try c.put("hello", value: "from swift!")
let v = try c.get("hello")
String.fromUtf8(v.value!)
let v2 = try c.get("wooow")
v2.exists

var d = try c.delete("hello")
d.exists
d = try c.delete("hello")
d.exists
 No newline at end of file
+17 −0
Original line number Diff line number Diff line
//: Playground - noun: a place where people can play

import Kinetic

// Connect to a device
// This creates a KineticSession against a KineticDevice
let c = Kinetic.connect("localhost", port: 8123)

// Write a key/value pair
try c.put("hello", value: "world")

// Read the value back
let x = try c.get("hello")

// The Strings on the methods are just for convenience
// the actual values are byte arrays ([UInt8])
print("Received: \(String.fromUtf8(x.value!))")
 No newline at end of file
Loading