读取和写入MetaData内容作为文档目录中的文件

时间:2014-04-22 10:00:47

标签: ios objective-c google-drive-api metadata

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString* arrayText = [MetaDataArray componentsJoinedByString: @"\n"];

    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"EmployeeData.txt"];

    [arrayText writeToFile:path atomically:YES];

MetaData Array first Object如下所示:

    {fileSize:"9385033" labels:{viewed,starred,restricted,trashed,hidden} 
originalFilename:"Chamak Challo - Ra.One (2011) [MP3-320Kbps-CBR].mp3" mimeType:"audio/mpeg" 
title:"Chamak Challo - Ra.One (2011) [MP3-320Kbps-CBR].mp3" parents:[1] 
md5Checksum:"51d598c750102dd4bca09addf4d8212d" quotaBytesUsed:"9385033" 
lastModifyingUserName:"shadow.hibrise" copyable?:1 
headRevisionId?:"0B7v4X9XjauwJR3dZM1FQWlpHeEFOZGYyYzR2NUdtLzhmb2FNPQ" kind:"drive#file" 
writersCanShare:1 appDataContents?:0 modifiedDate:"2014-03-04T11:13:32.649Z" shared?:0 
id:"0B7v4X9XjauwJdTUyeW5zTVRNTU0" ownerNames:[1] userPermission:{etag,kind,id,type,role}
 createdDate:"2014-03-04T11:13:32.649Z" fileExtension:"mp3" 
iconLink?:"https://ssl.gstatic.com/docs/doclist/images/icon_10_audio_list.png" 
modifiedByMeDate:"2014-03-04T11:13:32.634Z" downloadUrl:"https://doc-10-3s-
docs.googleusercontent.com/docs/securesc/0ijvatgpdej0qafpk7qtp7n2jgndtb3d/ifb42us5ai6ae9ah4kalfu4cnrtl6j3n/1398153600000/18240796891762319987/18240796891762319987/0B7v4X9XjauwJdTUyeW5zTVRNTU0?h=16653014193614665626&e=download&gd=true" lastModifyingUser?:{kind,displayName,permissionId,isAuthenticatedUser} editable:1 etag:""fgLq6vWOgR-hiHy-psxfsLtIDgQ/MTM5MzkzMTYxMjY0OQ"" webContentLink:"https://docs.google.com/uc?id=0B7v4X9XjauwJdTUyeW5zTVRNTU0&export=download" owners?:[1] alternateLink:"https://docs.google.com/file/d/0B7v4X9XjauwJdTUyeW5zTVRNTU0/edit?
usp=drivesdk"}

我想将对象数组存储为文件,反之亦然。

1 个答案:

答案 0 :(得分:1)

您可以使用Sqlite或核心数据而不是文件系统。

有关核心数据,请参阅此link

对于文件系统this可能很有用