1.十款不容错过的Swift iOS开源项目.

http://www.csdn.net/article/2014-10-16/2822083-swift-ios-open-source-projects

2.缓存框架 Haneke:

Haneke是一款使用Swift语言编写的,轻量级的iOS通用缓存。它为UIImage、NSData、JSON和String提供记忆和LRU磁盘缓存或其他像数据可以读取或写入的任何其他类型。特别地是,Haneke更擅长处理图像。使用要求:iOS 8.0+、Xcode 6.0。

https://github.com/Haneke/HanekeSwift

3.Alamofire网络库基础教程:

http://www.jianshu.com/p/f1208b5e42d9

http://www.jianshu.com/p/77a86824fa0f

github地址:https://github.com/Alamofire/Alamofire

使用:

- HTTP Methods

public enum Method: String {
case OPTIONS, GET, HEAD, POST, PUT, PATCH, DELETE, TRACE, CONNECT
} --------------------------- Alamofire.request(.POST, "https://httpbin.org/post") Alamofire.request(.PUT, "https://httpbin.org/put") Alamofire.request(.DELETE, "https://httpbin.org/delete")
  • GET Request With URL-Encoded Parameters
Alamofire.request(.GET, "https://httpbin.org/get", parameters: ["foo": "bar"])
// https://httpbin.org/get?foo=bar
  • POST Request With URL-Encoded Parameters
let parameters = [
"foo": "bar",
"baz": ["a", 1],
"qux": [
"x": 1,
"y": 2,
"z": 3
]
] Alamofire.request(.POST, "https://httpbin.org/post", parameters: parameters)
// HTTP body: foo=bar&baz[]=a&baz[]=1&qux[x]=1&qux[y]=2&qux[z]=3
  • POST Request with JSON-encoded Parameters
let parameters = [
"foo": [1,2,3],
"bar": [
"baz": "qux"
]
] Alamofire.request(.POST, "https://httpbin.org/post", parameters: parameters, encoding: .JSON)
// HTTP body: {"foo": [1, 2, 3], "bar": {"baz": "qux"}}
  • HTTP Headers
let headers = [
"Authorization": "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
"Accept": "application/json"
] Alamofire.request(.GET, "https://httpbin.org/get", headers: headers)
.responseJSON { response in
debugPrint(response)
}

上传upload:

  • Supported Upload Types
    File
Data
Stream
MultipartFormData
  • Uploading a File
let fileURL = NSBundle.mainBundle().URLForResource("Default", withExtension: "png")
Alamofire.upload(.POST, "https://httpbin.org/post", file: fileURL)
  • Uploading with Progress
Alamofire.upload(.POST, "https://httpbin.org/post", file: fileURL)
.progress { bytesWritten, totalBytesWritten, totalBytesExpectedToWrite in
print(totalBytesWritten) // This closure is NOT called on the main queue for performance
// reasons. To update your ui, dispatch to the main queue.
dispatch_async(dispatch_get_main_queue()) {
print("Total bytes written on main queue: \(totalBytesWritten)")
}
}
.validate()
.responseJSON { response in
debugPrint(response)
}
  • Uploading MultipartFormData
Alamofire.upload(
.POST,
"https://httpbin.org/post",
multipartFormData: { multipartFormData in
multipartFormData.appendBodyPart(fileURL: unicornImageURL, name: "unicorn")
multipartFormData.appendBodyPart(fileURL: rainbowImageURL, name: "rainbow")
},
encodingCompletion: { encodingResult in
switch encodingResult {
case .Success(let upload, _, _):
upload.responseJSON { response in
debugPrint(response)
}
case .Failure(let encodingError):
print(encodingError)
}
}
)

下载Downloading

Supported Download Types

Request
Resume Data
  • Downloading a File
Alamofire.download(.GET, "https://httpbin.org/stream/100") { temporaryURL, response in
let fileManager = NSFileManager.defaultManager()
let directoryURL = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0]
let pathComponent = response.suggestedFilename return directoryURL.URLByAppendingPathComponent(pathComponent!)
} 使用默认的下载的目录:Using the Default Download Destination let destination = Alamofire.Request.suggestedDownloadDestination(directory: .DocumentDirectory, domain: .UserDomainMask)
Alamofire.download(.GET, "https://httpbin.org/stream/100", destination: destination)
  • Downloading a File w/Progress
Alamofire.download(.GET, "https://httpbin.org/stream/100", destination: destination)
.progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
print(totalBytesRead) // This closure is NOT called on the main queue for performance
// reasons. To update your ui, dispatch to the main queue.
dispatch_async(dispatch_get_main_queue()) {
print("Total bytes read on main queue: \(totalBytesRead)")
}
}
.response { _, _, _, error in
if let error = error {
print("Failed with error: \(error)")
} else {
print("Downloaded file successfully")
}
}
  • Accessing Resume Data for Failed Downloads访问下载失败的恢复数据
Alamofire.download(.GET, "https://httpbin.org/stream/100", destination: destination)
.response { _, _, data, _ in
if let
data = data,
resumeDataString = NSString(data: data, encoding: NSUTF8StringEncoding)
{
print("Resume Data: \(resumeDataString)")
} else {
print("Resume Data was empty")
}
}
The data parameter is automatically populated with the resumeData if available.数据参数自动填充resumeData如果可用。
let download = Alamofire.download(.GET, "https://httpbin.org/stream/100", destination: destination)
download.response { _, _, _, _ in
if let
resumeData = download.resumeData,
resumeDataString = NSString(data: resumeData, encoding: NSUTF8StringEncoding)
{
print("Resume Data: \(resumeDataString)")
} else {
print("Resume Data was empty")
}
}

十款不容错过的Swift iOS开源项目及介绍的更多相关文章

  1. iOS开源项目周报0413

    由OpenDigg 出品的iOS开源项目周报第十六期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等. glidin ...

  2. iOS开源项目周报0406

    由OpenDigg 出品的iOS开源项目周报第十五期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等. Tangra ...

  3. iOS开源项目周报0330

    由OpenDigg 出品的iOS开源项目周报第十四期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等. FengNi ...

  4. iOS开源项目周报0316

    由OpenDigg 出品的iOS开源项目周报第十二期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等.GodEye  ...

  5. iOS开源项目周报0309

    由OpenDigg 出品的iOS开源项目周报第十期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等.LazyScro ...

  6. iOS开源项目周报0105

    由OpenDigg 出品的iOS开源项目周报第四期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开发方面的开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等. He ...

  7. iOS开源项目周报1229

    由OpenDigg 出品的iOS开源项目周报第三期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开发方面的开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等. Ma ...

  8. iOS开源项目周报1222

    由OpenDigg 出品的iOS开源项目周报第二期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开发方面的开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等. io ...

  9. iOS开源项目周报1215

    由OpenDigg 出品的iOS开源项目周报第一期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开发方面的开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等. PY ...

随机推荐

  1. 洛谷P4180 [Beijing2010组队]次小生成树Tree(最小生成树,LCT,主席树,倍增LCA,倍增,树链剖分)

    洛谷题目传送门 %%%TPLY巨佬和ysner巨佬%%% 他们的题解 思路分析 具体思路都在各位巨佬的题解中.这题做法挺多的,我就不对每个都详细讲了,泛泛而谈吧. 大多数算法都要用kruskal把最小 ...

  2. 【BZOJ2527】MET-Meteors(整体二分)

    [BZOJ2527]MET-Meteors(整体二分) 题面 BZOJ权限题,良心洛谷链接 题解 其实我也不会做 看了zsy博客才会做... 这题如果直接爆算做显然行不通 如果只有单次询问,我们就可以 ...

  3. Poj3683:Priest John's Busiest Day

    题意 n对夫妻要结婚,第i对夫妻结婚的婚礼持续时间为[Si, Ti],他们会举行一个仪式,仪式时间为Di,这个仪式只能举行在开头或者结尾举行,要么[Si, Si+Di],要么[Ti-Di, Ti],然 ...

  4. [HNOI2010]CHORUS 合唱队

    题面 Bzoj Sol 简单\(DP\) # include <bits/stdc++.h> # define IL inline # define RG register # defin ...

  5. java操作impala

    public class App { static String JDBC_DRIVER = "com.cloudera.impala.jdbc4.Driver"; static ...

  6. sql语句转为Model

    在跟数据库打交道的时候,有一个常用的应用,就是把数据库中的表转为程序中的对象,也就是说表中的列转为对象的属性.对于字段比较少的,我们可以直接复制过去改,但是字段数比较多的时候,借助工具类实现比较方便而 ...

  7. Rlwrap工具的安装和配置

    1.创建安装目录装备安装包 root权限 [root@dbsrc oracle]# mkdir /stage [root@dbsrc oracle]# chmod –R 777 /stage 从U盘将 ...

  8. autobase之配置文件

    配置文件内容: 1.db_info{},数据库链接属性,包括Oracle,dmdb,快立方 2.credit etc目录的路径 3.批量基础数据导入sql路径 4.用例执行日志存储目录路径 功能: 1 ...

  9. 温故而知新-set

    set:同map一样,关联式容器.在插入时就会进行排序,主要特点如下: 1.记录元素即是key值又是value值 2.插入的时候严格排序,底层是红黑树 3.删除元素时只要操作指针节点,无需进行内存的拷 ...

  10. Linux epoll源码--

    Linux系统运行源码剖析-epoll代码注释 理解了中断.等待队列.调度,你就能懂Linux的80%. --老子 转发的话,请注明出处哦:http://www.cnblogs.com/stoneha ...