CocoaPods trunk is moving to be read-only. Read more on the blog, there are 13 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Feb 2017 |
| SwiftSwift Version | 3.0 |
| SPMSupports SPM | ✗ |
Maintained by saman kumara.
SkyWite
SkyWite is an open-source and highly versatile multi-purpose frameworks. Clean code and sleek features make SkyWite an ideal choice. Powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use.
Achieve your deadlines by using SkyWite. You will save Hundred hours.
Start development using Skywite. Definitely you will be happy….! yeah..
SkyWite being developed in clean code and its sleek features make it the “Dream Framework” for any iOS / Macos developer. Its modular architecture and feature-rich APIs makes it very simple for development. SkyWite’s powerful networking abstraction is built using Cocoa, which makes it easily available for everyone,
Its core being developed on Objective C, makes it compatible on the following platforms :
iOS,
Mac OS X,
TV OS and
The next question that would pop for any developer is, why build a framework as such when there a many similar ones available. The answer was quite straight forward. 9 out of 10 frameworks out there in the market have the following features:
Above features are not only available on the other frameworks in the market, but is also available on SkyWite, but here is what makes SkyWite special:
As same as the swnetworking framework we released earlier, this framework also doesn’t have any issue. If you find any, I’ll fix them as soon as possible. Now we don’t need a team as there is no such issues to fix.
You need to add “SystemConfiguration” framework into your project before implement this.
#How to apply to Xcode project
#Architecture
SWRequest SWRequestSWGetSWPostSWMultiPartSWPutSWPatchSWDeleteSWHeadSWOfflineRequestMangerResponseType SWResponseDataTypeSWResponseJSONDataTypeSWResponseXMLDataTypeSWResponseStringDataTypeSWResponseUIImageTypeSWRequestDataTypeSWRequestFormDataSWRequestMultiFormDataSWRequestJSONDataReachability SWReachabilityFile SWMediaUIKit+SkyWite UIImageViewExtensionUIProgressViewExtensionNSURLSession ALL Requests will be NSURLSession. Session will add in to NSOperationQueue . Request creation , response serialization, network reachability handing and offline request as well.
GET Requestlet s = SWGet()
s.startDataTask(url: "", params:nil, success: { (task, object) in
}) { (task, error) in
print("error", error)
}If you want send parameters you have two options
let s = SWGet()
s.startDataTask(url: "", params:"name=this is name&address=your address", success: { (task, object) in
}) { (task, error) in
print("error", error)
}If you want to encdoe parameters and values you need to pass Dictionary object with keys/values.
let s = SWGet()
s.startDataTask(url: "", params:"name=this is name&address=your address", success: { (task, object) in
}) { (task, error) in
print("error", error)
}We are recommend to use second option because if you have & sign with parameter or value it will break sending values.
GET with Response typeAvailable as response types
SWResponseJSONDataType, SWResponseJSONDataType, SWResponseXMLDataType,SWResponseStringDataType,SWResponseUIImageType
You need set responseDataType.
// this response will be JSON
let s = SWGet()
s.responseDataType = SWResponseStringDataType()
s.startDataTask(url: "", params:nil, success: { (task, object) in
print("item", object)
}) { (task, error) in
print("error", error)
}GET with loading indicatorIf you set your parent view to method, loading indicator will be displayed.
let s = SWGet()
s.responseDataType = SWResponseDataType()
s.startDataTask(url: "", params:nil, parentView: self.view , success: { (task, object) in
print("item", object)
}) { (task, error) in
print("error", error)
}If you want custom loading view you need to add new nib file to your project and name it as ‘sw_loadingView’. It will be displayed on the screen.
If you want to access cached data on the response. You need to use relevant method that include cache block
let s = SWGet()
s.responseDataType = SWResponseStringDataType()
s.startDataTask(url: "", params: nil, parentView: self.view, cache: { (response, object) in
print("chache", object)
}, success: { (task, object) in
print("success", object)
}) { (task, error) in
print("success", error)
}POST request (simple)Cache, Loading view available for the on the relevant method. Please check available methods
let s = SWPost()
s.responseDataType = SWResponseStringDataType()
s.startDataTask(url: "", params:["name":"this is name", "address": "your address"] as AnyObject , success: { (task, object) in
print("item", object)
}) { (task, error) in
print("error", error)
}
let s2 = SWPost()
s2.responseDataType = SWResponseStringDataType()
s2.startDataTask(url: "", params:"saman=test" as AnyObject , success: { (task, object) in
print("item", object)
}) { (task, error) in
print("error", error)
}POST multipart requestIt is really easy.
let s = SWPost()
let image = NSImage(named: "skywite")
let imgData = pngRepresentationOfImage(image: image!)
let media1 = SWMedia(fileName: "imagefile.png", key: "image", data: imgData)
let media2 = SWMedia(fileName: "imagefile.jpg", key: "image2", mineType:"image/jpeg", data: imgData)
s.responseDataType = SWResponseStringDataType()
s.startUploadTask(url: "", files:[media1, media2] , params: ["name":"this is name", "address": "your address"] as AnyObject, success: { (task, object) in
}) { (task, error) in
}
//create with custom mine type one
let media2 = SWMedia(fileName: "imagefile.jpg", key: "image2", mineType:"image/jpeg", data: imgData)
PUT simple requestlet s = SWPut()
s.responseDataType = SWResponseStringDataType()
s.startDataTask(url: "", params:"saman=test" as AnyObject , success: { (task, object) in
print("item", object)
}) { (task, error) in
print("error", error)
}PATCH simple requestlet s = SWPatch()
s.responseDataType = SWResponseStringDataType()
s.startDataTask(url: "", params:"saman=test" as AnyObject , success: { (task, object) in
print("item", object)
}) { (task, error) in
print("error", error)
}
DELETE simple requestlet s = SWDelete()
s.responseDataType = SWResponseStringDataType()
s.startDataTask(url: "", params:"saman=test" as AnyObject , success: { (task, object) in
print("item", object)
}) { (task, error) in
print("error", error)
}
HEAD simple requestlet s = SWHead()
s.responseDataType = SWResponseStringDataType()
s.startDataTask(url: "", params:"saman=test" as AnyObject , success: { (task, object) in
print("item", object)
}) { (task, error) in
print("error", error)
}
all the following features averrable on all the request types.
eg : If you want to access you need to call relevant method that include cache block
If you want to add custom headers you can set to accessing request object.
let s = SWPost()
s.reqeust.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
s.responseDataType = SWResponseStringDataType()
s.startDataTask(url: "", params:["name":"this is name", "address": "your address"] as AnyObject , success: { (task, object) in
print("item", object)
}) { (task, error) in
print("error", error)
}If you want to change request timeout , you have to change property call timeOut.
let s = SWPost()
s.timeOut = 120
s.responseDataType = SWResponseStringDataType()
s.startDataTask(url: "", params:["name":"this is name", "address": "your address"] as AnyObject , success: { (task, object) in
print("item", object)
}) { (task, error) in
print("error", error)
}You need to sent object type for the responseDataType on all your requests.
//JSON
let s = SWPost()
s.responseDataType = SWResponseJSONDataType()
s.startDataTask(url: "" , params: ["name":"this is name for testing", "address": "your address"] as AnyObject, parentView: nil, sendLaterIfOffline: true, cache: { (cache, response) in
}, success: { (task, response) in
}) { (task, error) in
}
//String
let s2 = SWPost()
s2.responseDataType = SWResponseStringDataType()
s2.startDataTask(url: "" , params: ["name":"this is name for testing", "address": "your address"] as AnyObject, parentView: nil, sendLaterIfOffline: true, cache: { (cache, response) in
}, success: { (task, response) in
}) { (task, error) in
}UIImageView with SkyWite No need to download image and set to UIImageView anymore. You can set url to UIImageView.
// Please use only one method . you can see 4 methods :)
let imageView = UIImageView.init(frame: CGRect(x:0, y:0, width:300, height:300))
imageView.loadWithURLString(url: "")
imageView.loadWithURLString(url: "", loadFromCacheFirst: true)
imageView.loadWithURLString(url: "") { (image) in
}
imageView.loadWithURLString(url: "", loadFromCacheFirst: true) { (image) in
}New Reachability class to support block when change network status
available Status
NotReachable
WWAN
Wifi
if (SWReachability.getCurrentNetworkStatus() == .NotReachable) {
//connection not avaible
}
//if you want to get status chnage notification
SWReachability.checkNetowrk(currentNetworkStatus: { (currentStatus) in
}) { (changedStatus) in
}
let s = SWPost()
let image = UIImage(named: "skywite")
let imgData = UIImagePNGRepresentation(image!)
let media1 = SWMedia(fileName: "imagefile.png", key: "image", data: imgData!)
let media2 = SWMedia(fileName: "imagefile.jpg", key: "image2", mineType:"image/jpeg", data: imgData!)
s.responseDataType = SWResponseStringDataType()
s.startUploadTask(url: "http://localhost:3000/api/v1/users/users", files:[media1, media2] , params: ["name":"this is name", "address": "your address"] as AnyObject, success: { (task, object) in
}) { (task, error) in
}
progressView.setRequestForUpload(request: s)
let s = SWPost()
s.responseDataType = SWResponseJSONDataType()
s.startDownloadTask(url: "http://192.168.1.36:3000/api/v1/users/jobs" , params:nil , parentView: nil, sendLaterIfOffline: true, cache: { (cache, response) in
}, success: { (task, response) in
}) { (task, error) in
}
progressView.setRequestForDownload(request: s)You can set custom object to your request object as userObject . This will allow any type
let s = SWPost()
s.userObject = //any type object.
You can set tag for the request
let s = SWPost()
s.tag = 12;
SkyWite This is really simple. First of all you need to send offline request expire time. this is seconds
SWOfflineManager.requestExpireTime(seconds: 1300)You have methods with parameter passing sendLaterIfOllfine. Just pass YES. That’s it.
let s = SWPost()
s.responseDataType = SWResponseJSONDataType()
s.startDownloadTask(url: "http://192.168.1.36:3000/api/v1/users/jobs" , params:nil , parentView: nil, sendLaterIfOffline: true, cache: { (cache, response) in
}, success: { (task, response) in
}) { (task, error) in
}
If you want catch offline request you need to use following methods. Better to add following lines to your AppDelegate didFinishLaunchingWithOptions methods.
SWOfflineManager.sharedInstance.request(success: { (squreqeust, obj) in
}) { (request, error) in
}Please note you need to set tag or userObject to identify the request. userObject should be `‘NSCording’ support object
Please use following method to set task for UIProgressView
func setDownloadTask(task: URLSessionDownloadTask) {}
func setUploadTask(task: URLSessionUploadTask) {}SkyWite is owned and maintained bye the SkyWite
SkyWite was originally created by saman kumara. If you want to contact [email protected]
If you believe you have identified a security vulnerability with SkyWite, you should report it as soon as possible via email to [email protected]. Please do not post it to a public issue tracker.
Skywite is released under the MIT license. See LICENSE for details.