IOS - 打印COOKIE

?NSHTTPCookie

在iOS中使用NSHTTPCookie类封装一条cookie,通过NSHTTPCookie的方法读取到cookie的通用属性。

- (NSUInteger)version; 
- (NSString *)name;
- (NSString *)value;
- (NSString *)domain; 
- (NSString *)path;
- (BOOL)isSessionOnly;
现在,我们需要读取cookie字段中的CRFS-TOKEN字段,

NSHTTPCookieStorage *cookie=[NSHTTPCookieStoragesharedHTTPCookieStorage];

for (NSHTTPCookie *cookieitem in? [cookie cookies]) {

? ? ? NSLog(@"COOKIE PATH :: %@",cookieitem.path);

? ? ? NSLog(@"COOKIE VERSION :: %d",cookieitem.version);

? ? ? NSLog(@"COOKIE DOMAIN :: %@",cookieitem.domain);

? ? ? NSLog(@"COOKIE NAME :: %@",cookieitem.name);

? ? ? NSLog(@"COOKIE VALUE :: %@",cookieitem.value);

? ? ? NSLog(@"COOKIE ISSESSIONONLY ::%d",cookieitem.isSessionOnly);

}

查看运行结果:

这样我们就可以读取cookie中的字段值。

IOS - 打印COOKIE

时间: 2024-08-11 07:49:43

IOS - 打印COOKIE的相关文章

iOS 打印日志的保存 (一)

当我们真机调试app的时候,作为开发人员的我们可以很方便的通过Xcode的debug area查看相关的打印信息.而测试人员在对app进行测试的时候,一旦出现了crash,这时我们就需要把相关的打印信息保存下来, 以便后面进行查看追踪crash原因.在这里我们可以将打印信息写入沙盒系统中.不多说了,直接上代码. 1 - (void)redirectNSlogToDocumentFolder 2 { 3 if (isatty(STDOUT_FILENO)) 4 { 5 NSLog(@"真机调试,无

IOS 打印语句

打印width和height NSLog("width: %f, height: %f",self.View.frame.size.width, self.View.navigationBar.frame.size.height); 打印frame NSLog(@"%@",[NSValue valueWithCGRect:self.View.bounds]); IOS 打印语句

ios打印frame等格式

NSLog(@"%@",NSStringFromCGRect(pickerView.frame)); 或者 CFShow(NSStringFromCGRect(pickerView.frame)); 打印 CGSize : NSLog(@"%@",NSStringFromCGSize(someCG Size )); NSLog的格式如下所示: %@ 对象 %d, %i 整数 %hi 短整型 %lli 长整型 %u   无符整形 %f 浮点/双字 %0.2f  精度浮

iOS 打印出视图中所有的子视图的名称

使用递归: - (void)listSubviewsOfView:(UIView *)view { // Get the subviews of the view NSArray *subviews = [view subviews]; // Return if there are no subviews if ([subviews count] == 0) return; // COUNT CHECK LINE for (UIView *subview in subviews) { // Do

iOS保存cookie的方法

SURLRequest*request =[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com/"]]; NSURLConnection*connection =[NSURLConnection connectionWithRequest:request delegate:self]; -(void)connection:(NSURLConnection*)connection didRece

iOS 打印出视图中全部的子视图的名称

使用递归: - (void)listSubviewsOfView:(UIView *)view { // Get the subviews of the view NSArray *subviews = [view subviews]; // Return if there are no subviews if ([subviews count] == 0) return; // COUNT CHECK LINE for (UIView *subview in subviews) { // Do

ios 打印日志注意的点

1.常用的打印格式化字符 %@ 对象 %d,%i 整型 (%i的老写法) %hd 短整型 %ld , %lld 长整型 %u 无符整型 %f 浮点型和double型 %0.2f 精度浮点数,只保留两位小数 %o 八进制 %zu size_t %p 指针地址 %e float/double (科学计算) %g float/double (科学技术法) %x: 为32位的无符号整型数(unsigned int),打印使用数字0-9的十六进制,小写a-f; %X: 为32位的无符号整型数(unsign

iOS 打印 UI结构

NSLog(@"------------%@",[[UIApplication sharedApplication].keyWindow performSelector:@selector(recursiveDescription)]); 由于recursiveDescription是Apple的私有API,你在Document中找不到该API. 同样的,你无法通过 [self.view recursiveDescription]来调用,这样会编译失败.

iOS 打印系统字体

1 NSArray * array = [UIFont familyNames]; 2 3 for( NSString *familyName in array ){ 4 printf( "Family: %s \n", [familyName UTF8String] ); 5 NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName]; 6 for( NSString *fontName in fontNames )