DBQuota.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // DBQuotaInfo.m
  3. // DropboxSDK
  4. //
  5. // Created by Brian Smith on 5/3/10.
  6. // Copyright 2010 Dropbox, Inc. All rights reserved.
  7. //
  8. #import "DBQuota.h"
  9. @implementation DBQuota
  10. - (id)initWithDictionary:(NSDictionary*)dict {
  11. if ((self = [super init])) {
  12. normalConsumedBytes = [[dict objectForKey:@"normal"] longLongValue];
  13. sharedConsumedBytes = [[dict objectForKey:@"shared"] longLongValue];
  14. totalBytes = [[dict objectForKey:@"quota"] longLongValue];
  15. }
  16. return self;
  17. }
  18. - (void)dealloc {
  19. [super dealloc];
  20. }
  21. @synthesize normalConsumedBytes;
  22. @synthesize sharedConsumedBytes;
  23. @synthesize totalBytes;
  24. - (long long)totalConsumedBytes {
  25. return normalConsumedBytes + sharedConsumedBytes;
  26. }
  27. #pragma mark NSCoding methods
  28. - (void)encodeWithCoder:(NSCoder*)coder {
  29. [coder encodeInt64:normalConsumedBytes forKey:@"normalConsumedBytes"];
  30. [coder encodeInt64:sharedConsumedBytes forKey:@"sharedConsumedBytes"];
  31. [coder encodeInt64:totalBytes forKey:@"totalBytes"];
  32. }
  33. - (id)initWithCoder:(NSCoder*)coder {
  34. self = [super init];
  35. normalConsumedBytes = [coder decodeInt64ForKey:@"normalConsumedBytes"];
  36. sharedConsumedBytes = [coder decodeInt64ForKey:@"sharedConsumedBytes"];
  37. totalBytes = [coder decodeInt64ForKey:@"totalBytes"];
  38. return self;
  39. }
  40. @end