swift玩转cookie
创建NSHTTPCookie 在IOS中,每个Cookie数据都一个NSHTTPCookie对象,那我们就要手动创建一个NSHTTPCookie对象。 let cookie = NSHTTPCookie(properties: [ NSHTTPCookieName:"username", NSHTTPCookieValue:"devonios.com", NSHTTPCookiePath:"/", NSHTTPCookieDomain:"http://devonios.com"]) NSHTTPCookie类有一个构造函数,参数是一个字典类型,只需要提供几个必须的键即可。在DASH中,原话是这么说的: To successfully create a cookie, you must provide values for (at least) the NSHTTPCookiePath, NSHTTPCookieName, and NSHTTPCookieValue keys, and either the NSHTTPCookieOriginURL key or the NSHTTPCookieDomain key. 很明显,前三个是必须的,后两个选一个。NSHTTPCookie提供了预置的常量字符串,我们在字典的键中可以直接写。 let NSHTTPCookieComment: