我使用NSHTTPCookie创建了一个cookie。但是,当我创建到期日期正在转换为创建日期。这里是我的代码:NSHTTPCookie:expiresDate始终为空
NSMutableDictionary *cProperties = [NSMutableDictionary dictionary];
[cProperties setObject:@"31 May 2016 17:04:14 GMT" forKey:NSHTTPCookieExpires];
NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:];
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];
每控制台输出:
<NSHTTPCookie version:0 name:"myCookie"
expiresDate:(null) created:2016-05-31 16:32:37 +0000
sessionOnly:TRUE path:"/" isSecure:TRUE>
任何你知道与创建日期为什么我的expiresDate越来越开关?
我真的很感谢你的帮助。
[文档](https://developer.apple.com/期待的NSDate的值类型, library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSHTTPCookie_Class /#// apple_ref/doc/constant_group/HTTP_Cookie_Attribute_Keys)表示当通过属性设置时它接受'NSDate'或'NSString'。我同意使用'NSDate'虽然更好。 – trojanfoe
@trojanfoe是的,你是对的。 NSString是可以接受的。我认为问题是NSString的格式,它需要像“2016-06-01 23:50:39 +0000”,遵循NSDate或查看“创建”的值 – riowww