I'm using google drive files in my application. Accessing files, downloading files, uploading files are working as a charm. Now I'm trying to save the GTLDriveFile information on local(pList) by using NSCoding. Can you please help me to save this information into pList or suggest the best way to store this info in local
Steps followed:
- Google Authentication - done
- Querying Files - done
- Trying to save all file information into pList - I'm here now
Please refer this link for GTLDriveFile Class Structure https://developers.google.com/drive/ios/reference/ios-client/interface_g_t_l_drive_file
I've tried by this way, but i couldn't save the entire structure into it.
For Ex: .h file
#import "GTLDriveFile.h"
@interface sample : GTLDriveFile <NSCoding>
@end
.m file
#import "sample.h"
@implementation sample
//@synthesize File;
- (id)initWithCoder:(NSCoder *)aDecoder
{
if(self = [super init]) {
super.fileSize=[aDecoder decodeObjectForKey:@"fileSize"];
super.originalFilename=[aDecoder decodeObjectForKey:@"originalFilename"];
super.mimeType=[aDecoder decodeObjectForKey:@"mimeType"];
super.title=[aDecoder decodeObjectForKey:@"title"];
**super.parents=[aDecoder decodeObjectForKey:@"parents"];**
super.lastModifyingUserName=[aDecoder decodeObjectForKey:@"lastModifyingUserName"];
**super.copyable=[aDecoder decodeObjectForKey:@"copyable"];**
super.kind=[aDecoder decodeObjectForKey:@"kind"];
super.writersCanShare=[aDecoder decodeObjectForKey:@"writersCanShare"];
**super.appDataContents=[aDecoder decodeObjectForKey:@"appDataContents"];
super.modifiedDate=[aDecoder decodeObjectForKey:@"modifiedDate"];**
}
return self;
}
- (void)encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeObject: super.fileSize forKey:@"fileSize"];
[encoder encodeObject: super.originalFilename forKey:@"originalFilename"];
[encoder encodeObject: super.mimeType forKey:@"mimeType"];
[encoder encodeObject: super.title forKey:@"title"];
**[encoder encodeObject: super.parents forKey:@"parents"];**
[encoder encodeObject: super.lastModifyingUserName forKey:@"lastModifyingUserName"];
**[encoder encodeObject:copyable forKey:@"copyable"];**
[encoder encodeObject: super.kind forKey:@"kind"];
[encoder encodeObject: super.writersCanShare forKey:@"writersCanShare"];
**[encoder encodeObject:appDataContents forKey:@"appDataContents"];**
**[encoder encodeObject: super.modifiedDate forKey:@"modifiedDate"];**
}
@end
Problem was, i couldn't serialize/de-serialize the direct values like NSString, NSNUMBER, and etc. When I'm trying on some base object like "copyable", I'm getting an exception(please refer the bolded objects or refer the GTLDriveFile class reference from the above link).
Guys, please help me to save this info to local and suggest the best way to do this.
Thanks