轉自:http://blog.mugunthkumar.com/ios-components/mknetworkkit/
MKNetworkKit is an easily one of the most popular and powerful networking frameworks available for iOS.
It’s a open source component that’s actively maintained by me (and thanks for various other contributors).
Using MKNetworkKit
If you are using git, you can add MKNetworkKit as a submodule. Fire up your terminal and type
git submodule add git@
https://github.com/MugunthKumar/MKNetworkKit
Once the repository is downloaded, open it in Finder. Locate the directory MKNetworkKit and drag and drop it to your project. If you are building for iOS, remove the files NSAlertView+MKNetworkKitAdditions.h/m. Alternatively, if you are building for Mac, remove the files UIAlertView+MKNetworkKitAdditions.h/m. This is illustrated in the screenshot below.
Click the “Remove References” button to remove these two files from the project. The next step is to add the two system frameworks needed by MKNetworkKit. Open the “Build Phases” section of your target and link it against Security.Framework and SystemConfiguration.Framework.
You are good to go. Try a Build and Run.
Architecture
The complete functionality of MKNetworkKit centers around two classes, MKNetworkEngine and MKNetworkOperation. Can you imagine that? It’s that simple.
MKNetworkEngine is a class that models your …
/*
(
制作一個POST請求
多部分表單數據上傳
認證
基本的
消化
Windows NTLM身份
緩存你的反應
自定義緩存行為
作為圖像緩存替代使用MKNetworkKit。
通過子類的功能更強大的定制
發牌
MKNetworkKit使用麻省理工學院授權。這意味着,你應該歸功於我在你的關於屏幕。一個簡單的一行文本
)
*/
Making a simple GET request
Making a POST request
Multi-part form data upload
Authentication
Basic
Digest
Windows NTLM
Caching your responses
Customizing the cache behavior
Using MKNetworkKit as a Image Cache alternative.
More powerful customization through subclassing
Licensing
MKNetworkKit uses MIT Licensing. This means, you should attribute me in your About screen. A simple one line text
“This product uses MKNetworkKit by Mugunth Kumar”
in your product’s about page will suffice.
Attribution Free Licensing
If you work for a client and the client wants you to get an attribution-free license, or that you just want to support my effort, head on to the license store.
Third party featured posts
- Uploading an image using MKNetworkKit is a cakewalk. Follow this tutorial by Mike over at Go Feisty! blog to understand how to use MKNetworkKit to upload images.
- Manbolo games have been using plain NSURLConnection/NSMutableURLRequest for making network operations in their app. They switched to MKNetworkKit and are happy. You can read about it here.
- Cocoa Manifest covered about MKNetworkKit here.
You can find various other blog posts featuring MKNetworkKit. If you wrote one, let me know. I’ll feature it here.