ARC与MRC混编
给ARC项目添加MRC标记(-fno-objc-arc),也可以给MRC项目添加ARC标记(-fobjc-arc)
常用开源框架网:https://github.com
#import "ViewController.h"
#import "UIImageView+WebCache.h" //加载头文件
@interface ViewController ()
@property (nonatomic,strong)UIImageView *imageView;
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_imageView = [[UIImageViewalloc]initWithFrame:self.view.frame];
[self.viewaddSubview:_imageView];
[selfdemo1];
}
-(void)demo1{
NSString *imagePath =@"http://pic15.nipic.com/20110616/7034149_164010530126_2.jpg";
/*参数1:图片的下载地址
*参数2:占位图片
*参数3:可选项
*参数4:进度
*参数5:完成时执行的Block(回调) */
[self.imageViewsd_setImageWithURL:[NSURLURLWithString:imagePath]placeholderImage:niloptions:0progress:^(NSInteger receivedSize,NSInteger expectedSize) {
// NSLog(@"receivedSize %tu, expectedSize %tu",receivedSize,expectedSize);
NSLog(@"%ld",receivedSize*100/expectedSize); //下载进度
} completed:^(UIImage *image,NSError *error, SDImageCacheType cacheType,NSURL *imageURL) {
}];
}
常用框架