fix convenience constructor. Bump version

This commit is contained in:
Erik 2015-03-16 11:47:42 -04:00
parent 68da96f37d
commit 90187aa458
3 changed files with 11 additions and 9 deletions

View File

@ -38,9 +38,11 @@ import Socket_IO_Client_Swift
API API
=== ===
Constructor Constructors
----------- -----------
`init(socketURL: String, opts:[String: AnyObject]? = nil)` - Constructs a new client for the given URL. opts can be omitted (will use default values. See example) `init(socketURL: String, opts:NSDictionary? = nil)` - Constructs a new client for the given URL. opts can be omitted (will use default values. See example)
`convenience init(socketURL: String, options:NSDictionary? = nil)` - Same as above, but meant for Objective-C. See Objective-C Example.
Methods Methods
------- -------
1. `socket.on(name:String, callback:((data:NSArray?, ack:AckEmitter?) -> Void))` - Adds a handler for an event. Items are passed by an array. `ack` can be used to send an ack when one is requested. See example. 1. `socket.on(name:String, callback:((data:NSArray?, ack:AckEmitter?) -> Void))` - Adds a handler for an event. Items are passed by an array. `ack` can be used to send an ack when one is requested. See example.
@ -124,12 +126,12 @@ socket.connect()
Objective-C Example Objective-C Example
=================== ===================
```objective-c ```objective-c
SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:@"localhost:8080" opts:nil]; SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:@"localhost:8080" options:nil];
[socket on: @"connect" callback: ^(NSArray* data, void (^ack)(NSArray*)) { [socket on: @"connect" callback: ^(NSArray* data, void (^ack)(NSArray*)) {
NSLog(@"connected"); NSLog(@"connected");
[socket emitObjc:@"echo" :@[@"echo test"]]; [socket emitObjc:@"echo" :@[@"echo test"]];
[[socket emitWithAckObjc:@"ackack" :@[@"test"]] onAck:^(NSArray* data) { [[socket emitWithAckObjc:@"ackack" :@[@"test"]] onAck:0 withCallback:^(NSArray* data) {
NSLog(@"Got data"); NSLog(@"Got data");
}]; }];
}]; }];

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "Socket.IO-Client-Swift" s.name = "Socket.IO-Client-Swift"
s.version = "1.1.4" s.version = "1.1.5"
s.summary = "Socket.IO-client for Swift" s.summary = "Socket.IO-client for Swift"
s.description = <<-DESC s.description = <<-DESC
Socket.IO-client for Swift. Socket.IO-client for Swift.
@ -12,7 +12,7 @@ Pod::Spec.new do |s|
s.author = { "Erik" => "nuclear.ace@gmail.com" } s.author = { "Erik" => "nuclear.ace@gmail.com" }
s.ios.deployment_target = '8.0' s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10' s.osx.deployment_target = '10.10'
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v1.1.4' } s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v1.1.5' }
s.source_files = "SwiftIO/**/*.swift" s.source_files = "SwiftIO/**/*.swift"
s.requires_arc = true s.requires_arc = true
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files # s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files

View File

@ -74,7 +74,7 @@ public class SocketIOClient: NSObject {
return self._sid return self._sid
} }
public init(var socketURL:String, opts:[String: AnyObject]? = nil) { public init(var socketURL:String, opts:NSDictionary? = nil) {
if socketURL["https://"].matches().count != 0 { if socketURL["https://"].matches().count != 0 {
self._secure = true self._secure = true
} }
@ -116,8 +116,8 @@ public class SocketIOClient: NSObject {
self.engine = SocketEngine(client: self, forcePolling: self.forcePolling) self.engine = SocketEngine(client: self, forcePolling: self.forcePolling)
} }
public convenience init(socketURL:String, opts:NSDictionary?) { public convenience init(socketURL:String, options:NSDictionary?) {
self.init(socketURL: socketURL, opts: opts) self.init(socketURL: socketURL, opts: options)
} }
// Closes the socket // Closes the socket