Skip to content

Commit

Permalink
Merge pull request #55 from ishkawa/xcode7-beta4
Browse files Browse the repository at this point in the history
Updates for Xcode 7 beta 4
  • Loading branch information
ishkawa committed Jul 22, 2015
2 parents 96618ac + a5c6faf commit 5cfd2e6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
3 changes: 0 additions & 3 deletions APIKit/APIError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ public enum APIError: ErrorType {
/// Error in `RequestBodyBuilder.buildBodyFromObject()`.
case RequestBodySerializationError(ErrorType)

/// Failed to create `NSURLSessionDataTask` from `NSURLSession.dataTaskWithRequest()`.
case FailedToCreateURLSessionTask

/// Indicates `NSHTTPURLResponse.statusCode` is not contained in `Request.statusCode`.
/// Second associated value is return value of `errorFromObject()`.
case UnacceptableStatusCode(Int, ErrorType)
Expand Down
6 changes: 3 additions & 3 deletions APIKit/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public protocol Request {
var parameters: [String: AnyObject] { get }

/// You can add any configurations here
///
/// - Throws: ErrorType
func configureURLRequest(URLRequest: NSMutableURLRequest) throws -> NSMutableURLRequest

/// Set of status code that indicates success.
Expand Down Expand Up @@ -99,9 +101,7 @@ public extension Request {
return .Failure(.ConfigurationError(error))
}

guard let task = URLSession.dataTaskWithRequest(URLRequest) else {
return .Failure(.FailedToCreateURLSessionTask)
}
let task = URLSession.dataTaskWithRequest(URLRequest)

return .Success(task)
}
Expand Down
1 change: 1 addition & 0 deletions APIKit/RequestBodyBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum RequestBodyBuilder {
}
}

/// - Throws: NSError, URLEncodedSerialization.Error, ErrorType
public func buildBodyFromObject(object: AnyObject) throws -> NSData {
switch self {
case .JSON(let writingOptions):
Expand Down
1 change: 1 addition & 0 deletions APIKit/ResponseBodyParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum ResponseBodyParser {
}
}

/// - Throws: NSError, URLEncodedSerialization.Error, ErrorType
public func parseData(data: NSData) throws -> AnyObject {
switch self {
case .JSON(let readingOptions):
Expand Down
4 changes: 3 additions & 1 deletion APIKit/URLEncodedSerialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class URLEncodedSerialization {
case InvalidFormatString(String)
}

/// - Throws: URLEncodedSerialization.Error
public class func objectFromData(data: NSData, encoding: NSStringEncoding) throws -> [String: String] {
guard let string = NSString(data: data, encoding: encoding) as? String else {
throw Error.CannotGetStringFromData(data, encoding)
Expand All @@ -34,7 +35,8 @@ public class URLEncodedSerialization {

return dictionary
}


/// - Throws: URLEncodedSerialization.Error
public class func dataFromObject(object: AnyObject, encoding: NSStringEncoding) throws -> NSData {
guard let dictionary = object as? [String: AnyObject] else {
throw Error.CannotCastObjectToDictionary(object)
Expand Down

0 comments on commit 5cfd2e6

Please sign in to comment.