2
0

DNAsset.m 850 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // DNAsset.m
  3. // ImagePicker
  4. //
  5. // Created by DingXiao on 15/3/6.
  6. // Copyright (c) 2015年 Dennis. All rights reserved.
  7. //
  8. #import "DNAsset.h"
  9. #import <Photos/Photos.h>
  10. @interface DNAsset ()
  11. @property (nonatomic, strong, nullable) PHAsset *asset;
  12. @end
  13. @implementation DNAsset
  14. - (instancetype)init {
  15. self = [super init];
  16. if (self) {
  17. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarningInAssets) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
  18. }
  19. return self;
  20. }
  21. + (DNAsset *)assetWithPHAsset:(PHAsset *)asset {
  22. DNAsset *a = [[DNAsset alloc] init];
  23. if (!asset) {
  24. return a;
  25. }
  26. a.asset = asset;
  27. a.assetIdentifier = asset.localIdentifier;
  28. return a;
  29. }
  30. - (void)didReceiveMemoryWarningInAssets {
  31. _cacheImage = nil;
  32. }
  33. @end