Container *container = [[[Container alloc] init] autorelease];
// regular attributes
container.name = [dict objectForKey:@"name"];
- container.count = [[dict objectForKey:@"count"] unsignedIntegerValue];
- container.bytes = [[dict objectForKey:@"bytes"] unsignedLongLongValue];
-
- //policy
- container.versioning = [[dict objectForKey:@"x_container_policy"] objectForKey:@"versioning"];
- // we lose precision in the quota for now, this should be turned to unsigned long long
- container.quota = strtoul([[[dict objectForKey:@"x_container_policy"] objectForKey:@"quota"] UTF8String], NULL, 0);
-
- // metadata
- container.metadata = nil;
+ if ([dict objectForKey:@"count"]) {
+ // If "count" doesn't exist then it is a "shared to me" container, where only "name" exists
+ container.count = [[dict objectForKey:@"count"] unsignedIntegerValue];
+ container.bytes = [[dict objectForKey:@"bytes"] unsignedLongLongValue];
+
+ // policy
+ container.versioning = [[dict objectForKey:@"x_container_policy"] objectForKey:@"versioning"];
+ // we lose precision in the quota for now, this should be turned to unsigned long long
+ container.quota = strtoul([[[dict objectForKey:@"x_container_policy"] objectForKey:@"quota"] UTF8String], NULL, 0);
+ }
+ // metadata are created elsewhere, so are left nil
return container;
}