Repository navigation
Expand file tree
/
Copy pathDropboxModel.m
More file actions
101 lines (79 loc) · 2.79 KB
/
Copy pathDropboxModel.m
File metadata and controls
101 lines (79 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//
// DropboxModel.m
// DropboxCollection
//
// Created by Ryan Mullins on 8/14/12.
// Copyright (c) 2012 com.apple.cocoacamp. All rights reserved.
//
#import "DropboxModel.h"
@interface DropboxModel() <DBRestClientDelegate>
@property (nonatomic, strong) DBRestClient * restClient;
@end
@implementation DropboxModel
@synthesize activeDirectories;
+ (DropboxModel *) sharedInstance {
static DropboxModel * model;
if (!model) {
model = [[DropboxModel alloc] init];
}
return model;
}
- (id) init {
self = [super init];
if (self) {
activeDirectories = [[NSMutableArray alloc] init];
}
return self;
}
- (DBMetadata *) metaDataForItemAtIndex:(NSUInteger)index {
/* BUG:
*
* When accessing the TableViews for multiple directories, if one kicks off a
* call to the datamodel to load a new directory and another TableView is
* still being touched on the interface and error will occur where the second
* TableView will register a new event of some sort but the
* TableViewController for that second TableView has been removed from the
* system and cannot be accessed so the app breaks.
*
* SOLUTION:
*
* When interacting with any one table view, turn off selection of cells in
* all other visible table views.
*/
return [[self activeDirectories] objectAtIndex:index];
}
- (void) jumpBackToDirectoryAtIndex:(NSUInteger)index {
for (int i = [[self activeDirectories] count] - 1; i > index; i--) {
[[self activeDirectories] removeLastObject];
}
}
- (void) loadMetadataForPath:(NSString *)path {
[[self restClient] loadMetadata:path];
}
- (void) loadFile:(NSString *)dropboxPath intoPath:(NSString *)destinationPath {
/* I feel like this might be part of the error */
[[self restClient] loadFile:dropboxPath intoPath:destinationPath];
}
#pragma mark - DropboxSDK
- (DBRestClient *) restClient {
if (!_restClient) {
_restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
[_restClient setDelegate:self];
}
return _restClient;
}
- (void) restClient:(DBRestClient *)client loadedFile:(NSString *)destPath {
[self setFilePath:destPath];
}
- (void) restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata {
NSMutableArray * hackArray = [[NSMutableArray alloc] initWithArray:[self activeDirectories]];
[hackArray addObject:metadata];
[self setActiveDirectories:hackArray];
}
- (void) restClient:(DBRestClient *)client loadFileFailedWithError:(NSError *)error {
NSLog(@"ERROR: REST client could not load file. %@", error);
}
- (void) restClient:(DBRestClient *)client loadMetadataFailedWithError:(NSError *)error {
NSLog(@"ERROR: REST client could not load metadata. %@", error);
}
@end