进度条相关的操作都定义在
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;
今天,遇见了一个很奇怪的问题,在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);
}
}
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];