-
子类实现父类方法时,监测子类是否调用super方法。
在父类中声明方法时:
- (void)functionWith:(NSArray*)arr1 string:(NSString*)string arr:(NSArray*)arr2NS_REQUIRES_SUPER;
子类中实现该父类方法:
- (void)functionWith:(NSArray *)arr1string:(NSString *)stringarr:(NSArray *)arr2 {//不调用super方法,报警告⚠️[superfunctionWith:nilstring:nilarr:nil];}
-
图片压缩
func imageCompress(targetWidth:CGFloat) -> UIIMage {
let targetHeight = targetWidth/width*height
UIGraphicsBeginImageContext(CGSizeMake(targetWidth,targetHeight))
self.drawInRect(CGRectMake(0,0,targetWidth,targetHeight))
let newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGrapicsEndImageContext()
return newImage
}
网友评论