我正在使用Erica Sadun的异步下载方法(此处链接到项目文件:下载),但是她的方法不适用于具有大尺寸(50 mb或更高)的文件.如果我尝试下载超过50 MB的文件,它通常会因内存崩溃而崩溃.无论如何我可以调整这段代码,以便它也适用于大文件?这是我在DownloadHelper类中的代码(已经在下载链接中):
.H
@protocol DownloadHelperDelegate <NSObject>
@optional
- (void) didReceiveData: (NSData *) theData;
- (void) didReceiveFilename: (NSString *) aName;
- (void) dataDownloadFailed: (NSString *) reason;
- (void) dataDownloadAtPercent: (NSNumber *) aPercent;
@end
@interface DownloadHelper : NSObject
{
NSURLResponse *response;
NSMutableData *data;
NSString *urlString;
NSURLConnection *urlconnection;
id <DownloadHelperDelegate> delegate;
BOOL isDownloading;
}
@property (retain) NSURLResponse *response;
@property (retain) NSURLConnection *urlconnection;
@property (retain) NSMutableData *data;
@property (retain) NSString *urlString;
@property (retain) id delegate;
@property (assign) BOOL isDownloading;
+ …Run Code Online (Sandbox Code Playgroud)