1
Dropbox iOS API를 사용하여 다른 기기를 동기화합니다. 다음 코드를 사용하여 최신 파일을 다운로드하거나 업로드 할 때 파일이 수정 된 날짜를 비교하려고합니다. 문제는 단지 다운로드 중이며 결코 업로드하지 않는다는 것입니다. 어떤 힌트?Dropbox iOS API 및 NSDate를 사용하여 파일을 다운로드하거나 업로드 할 수 없음
- (void)dropboxAuth {
if (![[DBSession sharedSession] isLinked]) {
[[DBSession sharedSession] link];
}
else {
NSString *filename = @"NotesList.plist";
NSString *destDir = @"/";
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString *address = [documentsDir stringByAppendingPathComponent:@"NotesList.plist"];
[[self restClient] loadMetadata:@"/"];
if([[NSFileManager defaultManager] fileExistsAtPath:address]) {
NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfItemAtPath:address error:&error];
NSDate *fileDate =[dictionary objectForKey:NSFileModificationDate];
if ([[fileDate earlierDate:self.metaData.lastModifiedDate]isEqualToDate:fileDate]) {
[self.restClient loadFile:[NSString stringWithFormat: @"%@/%@", destDir, filename]
intoPath:address];
NSLog(@"Downloading");
}
else if ([[self.metaData.lastModifiedDate earlierDate:fileDate] isEqualToDate:self.metaData.lastModifiedDate]) {
[[self restClient] uploadFile:filename toPath:destDir fromPath:address];
NSLog(@"Uploading");
}
}
}
}
유용한 게시물 찾기 : http://stackoverflow.com/questions/5950168/a-simple-sync-with-the-iphone-dropbox-api – mstottrop