UIWebView存储网页

将文件流存储成本地文件的方法,下次加载的时候,判断下本地是否已经存在文件即可

NSString            *name        = [[NSString alloc] initWithCString:"文件名" encoding:NSUTF8StringEncoding ];
NSError        *error        = nil;
NSArray        *paths        = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString       *documentsDirectory = [paths objectAtIndex:0];
NSString            *localFile    = [documentsDirectory stringByAppendingPathComponent:name];
NSMutableData *theData = [[NSMutableData alloc] initWithCapacity:100];
[theData appendBytes:&buff[0] length:iAllCount];
[theData writeToFile:localFile options:NSDataWritingAtomic error:&error];
[theData release];

你可能感兴趣的:(UIWebView存储网页)