NSKeyedUnarchiver+YYAdd.m 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // NSKeyedUnarchiver+YYAdd.m
  3. // YYKit <https://github.com/ibireme/YYKit>
  4. //
  5. // Created by ibireme on 13/8/4.
  6. // Copyright (c) 2015 ibireme.
  7. //
  8. // This source code is licensed under the MIT-style license found in the
  9. // LICENSE file in the root directory of this source tree.
  10. //
  11. #import "NSKeyedUnarchiver+YYAdd.h"
  12. #import "YYKitMacro.h"
  13. YYSYNTH_DUMMY_CLASS(NSKeyedUnarchiver_YYAdd)
  14. @implementation NSKeyedUnarchiver (YYAdd)
  15. + (id)unarchiveObjectWithData:(NSData *)data exception:(__autoreleasing NSException **)exception {
  16. id object = nil;
  17. @try {
  18. object = [NSKeyedUnarchiver unarchiveObjectWithData:data];
  19. }
  20. @catch (NSException *e)
  21. {
  22. if (exception) *exception = e;
  23. }
  24. @finally
  25. {
  26. }
  27. return object;
  28. }
  29. + (id)unarchiveObjectWithFile:(NSString *)path exception:(__autoreleasing NSException **)exception {
  30. id object = nil;
  31. @try {
  32. object = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
  33. }
  34. @catch (NSException *e)
  35. {
  36. if (exception) *exception = e;
  37. }
  38. @finally
  39. {
  40. }
  41. return object;
  42. }
  43. @end