[英]unrecognized selector sent to instance defaultRepresentation ios 8
Below is my code which was working on previous version but in iOS 8 app gets crashed. 下面是我的代码,该代码在以前的版本上运行,但是在iOS 8应用中崩溃了。 Please help. 请帮忙。
ALAsset *asset = self.mArrassets[indexPath.row];
// NSURL *savedAssetUrl =asset.defaultRepresentation.url;
ALAssetRepresentation *representation = [asset defaultRepresentation];
NSURL *savedAssetUrl =[representation url];
That probably means that self.mArrassets
has at least one object that is not ALAsset
. 这可能意味着self.mArrassets
至少具有一个不是ALAsset
对象。 NSArray
may not determine what kind of an object stores. NSArray
可能无法确定存储哪种对象。 It must be reference type thats all. 它必须是引用类型,仅此而已。
The code below shows how to avoid such problems: 下面的代码显示了如何避免此类问题:
NSObject *asset = self.mArrassets[indexPath.row];
if ([asset isKindOfClass:[ALAsset class]]) {
// NSURL *savedAssetUrl =asset.defaultRepresentation.url;
ALAssetRepresentation *representation = [asset defaultRepresentation];
NSURL *savedAssetUrl =[representation url];
}
else {
NSLog(@" this is not ALAsset! The class is %@", [asset class]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.