CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
CocoaPods 1.1+ is required to build StorageManager.
To integrate StorageManager into your Xcode project using CocoaPods, specify it in your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'Dots'
end
Then, run the following command:
$ pod install
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate StorageManager into your Xcode project using Carthage, specify it in your Cartfile:
github "iAmrSalman/Dots" ~> 0.5.0
Run carthage update to build the framework and drag the built Dots.framework into your Xcode project.
Swift Package Manager
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but StorageManager does support its use on supported platforms.
Once you have your Swift package set up, adding StorageManager as a dependency is as easy as adding it to the dependencies value of your Package.swift.
import Dots
Dots.defualt.request("<URL>") { (dot: Dot) in
print(dot.response) // HTTP URL response
print(dot.data) // server data
print(dot.error) // Errors from request processing
print(dot.json) // JSON dictionary [String: Any]
}
HTTP Methods
The HTTPMethod enumeration lists the HTTP methods:
public enum HTTPMethod: String {
case options = "OPTIONS"
case get = "GET"
case head = "HEAD"
case post = "POST"
case put = "PUT"
case patch = "PATCH"
case delete = "DELETE"
case trace = "TRACE"
case connect = "CONNECT"
}
These values can be passed as the method argument to the request Function:
Customizing Maximum concurrent requests executing simultaneously is supported.
The defualt is checking if device is on cellular connection, maximum concurrent requests is restricted to 2, while Wi-Fi is executing up to 6 simultaneous requests.
let customDots = Dots(maxConcurrentOperation: <Int>)
customDots.request("<URL>")
Dots
Example
To run the example project, clone the repo, and run
pod install
from the Example directory first.Requirements
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
To integrate StorageManager into your Xcode project using CocoaPods, specify it in your
Podfile
:Then, run the following command:
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
To integrate StorageManager into your Xcode project using Carthage, specify it in your
Cartfile
:Run
carthage update
to build the framework and drag the builtDots.framework
into your Xcode project.Swift Package Manager
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the
swift
compiler. It is in early development, but StorageManager does support its use on supported platforms.Once you have your Swift package set up, adding StorageManager as a dependency is as easy as adding it to the
dependencies
value of yourPackage.swift
.Usage
Making a Request
HTTP Methods
The
HTTPMethod
enumeration lists the HTTP methods:These values can be passed as the
method
argument to therequest
Function:The
request
method parameter defaults to.get
.Parameter Encoding
GET Request With URL-Encoded Parameters
POST Request With URL-Encoded Parameters
POST Request With JSON-Encoded Parameters
HTTP Headers
Adding a custom HTTP header to a
Request
is supported directly in the globalrequest
method. This makes it easy to attach HTTP headers to aRequest
.Concurrency
Choosing between Asynchronous and Synchronous is supported
Maximum concurrent requests
Customizing Maximum concurrent requests executing simultaneously is supported.
The defualt is checking if device is on cellular connection, maximum concurrent requests is restricted to 2, while Wi-Fi is executing up to 6 simultaneous requests.
Extensions
UIImageView
Author
Amr Salman, iamrsalman@gmail.com
License
Dots is available under the MIT license. See the LICENSE file for more info.