ASIHttpRequest下载服务端的mp3...文件

我的实现的代码 :(原来如此简单)

NSString * path=[ NSSearchPathForDirectoriesInDomains (NSDocumentDirectory , NSUserDomainMask ,YES ) objectAtIndex :0 ];

    path=[path stringByAppendingPathComponent :@"li.amr" ];

    NSURL *url = [NSURL URLWithString :@"http://www.chihuo876.com/Public/Uploads/mobile/Vedio/51c1117f85337.amr" ];

    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL :url];

    [request setDownloadDestinationPath :path];

    [request startSynchronous ];



这几个是群里兄弟推荐的:http://www.cocoachina.com/bbs/read.php?tid=10072

http://blog.sina.com.cn/s/blog_86eee82e0101c86e.html

http://www.cnblogs.com/jjtech/archive/2011/04/17/2019210.html


转载自:http://blog.csdn.net/kmyhy/article/details/6524916

1、简单下载

打开IB,拖入一个Progress View,在源文件中声明为IBOutlet,然后进行连接。

-( IBAction )goURL{

NSString * path=[ NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory ,NSUserDomainMask YES objectAtIndex : 0 ];

path=[path stringByAppendingPathComponent @"plsqldev714.rar" ];

NSURL *url = [ NSURL URLWithString : @"http://localhost/upload/plsqldev714.rar" ];

ASIHTTPRequest *request = [ ASIHTTPRequest requestWithURL :url];

[request setDownloadDestinationPath :path];

[request setDownloadProgressDelegate : progressView ];

[request startSynchronous ];

}

 

运行程序,下载进度会在progress view中显示。下载进度显示当前完成的大约比例。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值