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:
- Support all request methods
- Offline request support
- HTTP request operation manager
- Cocoa Pod Support
- SWIFT Compatible
- Supports Apple UI Kit.
- Background request support
- Session manager
- Reachability manager
- Secured
- Free support offered around the framework
- The framework will be continuously updated with the new OS drops
- Community around the framework to support bug fixes
- Code amendment flexibility
- 99% Guaranteed on crash management for the framework
- Block support
- MIT License
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:
- Offline sync support
- The frameworks adds in a loading indicator when a request is sent, allows for addition of custom indicators as well
- A sing line of code to initiate a request, which will approximately save 20 lines of code
- Block with background request
- Tag a request (set int value to identify requests)
- Set priority for offline requests.
- All the request/response body will generated automatically which would save the developer approximately 50-70 lines of coding
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
- Download Skywite from gitHub
- Add required frameworks
SkyWite is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "SkyWite"
If you are new to CocoaPods, please go to Wiki page.
- If you need any help, use Stack Overflow. (Tag 'skywite') or you can send a mail with details ( we will provide fast feedback )
- If you'd like to ask a general question, use Stack Overflow.
- If you found a bug, and can provide steps to reliably reproduce it, open an issue or you can contribute.
- If you have a feature request, send a request mail we will add as soon as possible.
- If you want to contribute, submit a pull request.
#Architecture
SWRequest
SWRequest
SWGet
SWPost
SWMultiPart
SWPut
SWPatch
SWDelete
SWHead
SWOfflineRequestManger
ResponseType
SWResponseDataType
SWResponseJSONDataType
SWResponseXMLDataType
SWResponseStringDataType
SWResponseUIImageType
SWRequestDataType
SWRequestFormData
SWRequestMultiFormData
SWRequestJSONData
Reachability
SWReachability
File
SWMedia
UIKit+SkyWite
UIImageViewExtension
UIProgressViewExtension
ALL Requests will be NSURLSession. Session will add in to NSOperationQueue
. Request creation , response serialization, network reachability handing and offline request as well.
let 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.
Available 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)
}
If 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)
}
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)
}
It 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)
let 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)
}
let 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)
}
let 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)
}
let 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
}
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;
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.