CocoaShare/Classes/Dropbox/DropboxSDK/DBQuota.m
2011-02-01 10:19:26 -06:00

57 lines
1.4 KiB
Objective-C

//
// DBQuotaInfo.m
// DropboxSDK
//
// Created by Brian Smith on 5/3/10.
// Copyright 2010 Dropbox, Inc. All rights reserved.
//
#import "DBQuota.h"
@implementation DBQuota
- (id)initWithDictionary:(NSDictionary*)dict {
if ((self = [super init])) {
normalConsumedBytes = [[dict objectForKey:@"normal"] longLongValue];
sharedConsumedBytes = [[dict objectForKey:@"shared"] longLongValue];
totalBytes = [[dict objectForKey:@"quota"] longLongValue];
}
return self;
}
- (void)dealloc {
[super dealloc];
}
- (long long)normalConsumedBytes {
return normalConsumedBytes;
}
- (long long)sharedConsumedBytes {
return sharedConsumedBytes;
}
- (long long)totalConsumedBytes {
return normalConsumedBytes + sharedConsumedBytes;
}
- (long long)totalBytes {
return totalBytes;
}
#pragma mark NSCoding methods
- (void)encodeWithCoder:(NSCoder*)coder {
[coder encodeInt64:normalConsumedBytes forKey:@"normalConsumedBytes"];
[coder encodeInt64:sharedConsumedBytes forKey:@"sharedConsumedBytes"];
[coder encodeInt64:totalBytes forKey:@"totalBytes"];
}
- (id)initWithCoder:(NSCoder*)coder {
self = [super init];
normalConsumedBytes = [coder decodeInt64ForKey:@"normalConsumedBytes"];
sharedConsumedBytes = [coder decodeInt64ForKey:@"sharedConsumedBytes"];
totalBytes = [coder decodeInt64ForKey:@"totalBytes"];
return self;
}
@end