iProgrammer
iProgrammer

Reputation: 3107

Dropbox Api in iphone

I am trying to integrate dropbox with iphone and done with login option.I want to load folders and files on root path in table view just after login.

code for this is

- (void)viewWillAppear:(BOOL)animated {
          [self.restClient loadMetadata:@"/"];
}

This loadMetadata is method in DBRestClient.m class.I managed to print json value on console

Code is

- (void)parseMetadataWithRequest:(DBRequest*)request {
    NSAutoreleasePool* pool = [NSAutoreleasePool new];

    NSDictionary* result = (NSDictionary*)[request resultJSON];
    DBMetadata* metadata = [[[DBMetadata alloc] initWithDictionary:result] autorelease];
    [self performSelectorOnMainThread:@selector(didParseMetadata:) withObject:metadata waitUntilDone:NO];
    NSLog(@"Meta data is :%@",result);
    [pool drain];
}

How could I use this result value in my view controller to display this in tableview?

Upvotes: 4

Views: 1593

Answers (1)

WrightsCS
WrightsCS

Reputation: 50697

Get the contents of a directory and put them into an array.

- (void)restClient:(DBRestClient*)client loadedMetadata:(DBMetadata*)metadata 
{
    for (DBMetadata* child in metadata.contents) 
    {
        if (child.isDirectory)
        {
            [self.restClient loadMetadata:child.path withHash:hash];
        } 
        else 
        {
            if ( [self.directory isEqualToString:@"a directory"] ) {
                /*  child.path is the file, so put it into an array  */                                                                                          
            }
        }
    }
}

Than load your array into your UITableView as you would any other NSArray / NSMutableArray

Upvotes: 2

Related Questions