当前位置:  编程技术>移动开发
本页文章导读:
    ▪asihttp 源码分析 之4 获取请求进度        asihttp 源码分析 之四 获取请求进度 进度条相关的操作都定义在 ASIProgressDelegate .h 文件中。 而且所有的方法都是optional的。   ipone上更新进度条的方法 :- (void)setProgress:(float)newProgress;   #if TA.........
    ▪ Simple中的Date的序列化有关问题        Simple中的Date的序列化问题 今天,遇见了一个很奇怪的问题,在Android模拟器上运行程序时,没有问题,可是到真机上运行,则会报ParseDate的异常,后来问了大神,是这样解决的,将一个Date类.........
    ▪ asihttp 源码分析 之4 session       asihttp 源码分析 之四 session session 相关的变量 // In memory caches of credentials, used on when useSessionPersistence is YESstatic NSMutableArray *sessionCredentialsStore = nil;static NSMutableArray *sessionProxyCredentialsStore = nil; //.........

[1]asihttp 源码分析 之4 获取请求进度
    来源: 互联网  发布时间: 2014-02-18
asihttp 源码分析 之四 获取请求进度

进度条相关的操作都定义在

ASIProgressDelegate .h 文件中。

而且所有的方法都是optional的。

 

ipone上更新进度条的方法 :- (void)setProgress:(float)newProgress;

 

#if TARGET_OS_IPHONE
- (void)setProgress:(float)newProgress;
#else
- (void)setDoubleValue:(double)newProgress;
- (void)setMaxValue:(double)newMax;
#endif

 

 

 

并且这个方法 直接是 @interface UIProgressView : UIView <NSCoding> 类中实现的。所有可以直接把UIProgressView 的实例赋值给ASIHTTPRequest下面的两个属性,而无需实现 ASIProgressDelegate 协议。

 

// Delegate for displaying upload progress (usually an NSProgressIndicator, but you can supply a different object and handle this yourself)
 id <ASIProgressDelegate> uploadProgressDelegate;
 
 // Delegate for displaying download progress (usually an NSProgressIndicator, but you can supply a different object and handle this yourself)
 id <ASIProgressDelegate> downloadProgressDelegate;

 

 

更新进度条的方法

 

// Updates upload progress (notifies the queue and/or uploadProgressDelegate of this request)
- (void)updateUploadProgress;

// Updates download progress (notifies the queue and/or uploadProgressDelegate of this request)
- (void)updateDownloadProgress;

 


    
[2] Simple中的Date的序列化有关问题
    来源: 互联网  发布时间: 2014-02-18
Simple中的Date的序列化问题

今天,遇见了一个很奇怪的问题,在Android模拟器上运行程序时,没有问题,可是到真机上运行,则会报ParseDate的异常,后来问了大神,是这样解决的,将一个Date类型的数据不直接序列化,而是将它所对应的秒来进行序列化,如下

 

//@Element(required = false)  这个一定不需要 注释掉

Date birthDay;

 

@Element(required = false)

public long getBirthdayTimeMills {

Date date = getBirthday();

if(date!= null) {

return date.getTime();

} else {

return -1;

}

}

 

@Element(required = false)

public void setBirthdayTimeMills(long birthdayTimeMills) {

if(birthdayTimeMills != -1) {

Date date = new Date(birthdayTimeMills);

}

}

 

 

 

 

 


    
[3] asihttp 源码分析 之4 session
    来源: 互联网  发布时间: 2014-02-18
asihttp 源码分析 之四 session

session 相关的变量

// In memory caches of credentials, used on when useSessionPersistence is YES
static NSMutableArray *sessionCredentialsStore = nil;
static NSMutableArray *sessionProxyCredentialsStore = nil;

// This lock mediates access to session credentials
static NSRecursiveLock *sessionCredentialsLock = nil;

// We keep track of cookies we have received here so we can remove them from the sharedHTTPCookieStorage later
static NSMutableArray *sessionCookies = nil;

 

session信息被存储的内存中。

 

开启session ,useSessionPersistence = yes。

 

- (void)readResponseHeaders方法中生产并存储session信息

 

 // Authentication succeeded, or no authentication was required
 if (![self authenticationNeeded]) {

  // Did we get here without an authentication challenge? (which can happen when shouldPresentCredentialsBeforeChallenge is YES and basic auth was successful)
  if (!requestAuthentication && [self username] && [self password] && [self useSessionPersistence]) {
   
   NSMutableDictionary *newCredentials = [NSMutableDictionary dictionaryWithCapacity:2];
   [newCredentials setObject:[self username] forKey:(NSString *)kCFHTTPAuthenticationUsername];
   [newCredentials setObject:[self password] forKey:(NSString *)kCFHTTPAuthenticationPassword];
   
   // Store the credentials in the session 
   NSMutableDictionary *sessionCredentials = [NSMutableDictionary dictionary];
   [sessionCredentials setObject:newCredentials forKey:@"Credentials"];
   [sessionCredentials setObject:[self url] forKey:@"URL"];
   [sessionCredentials setObject:(NSString *)kCFHTTPAuthenticationSchemeBasic forKey:@"AuthenticationScheme"];
   [[self class] storeAuthenticationCredentialsInSessionStore:sessionCredentials];
  }
 }

 

 

 [newCredentials setObject:[self username] forKey:(NSString *)kCFHTTPAuthenticationUsername];
   [newCredentials setObject:[self password] forKey:(NSString *)kCFHTTPAuthenticationPassword];


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3