2011-05-21 95 views
4

我想將dropbox與iphone集成,並使用登錄選項完成。我想在登錄後在表視圖中的根路徑上加載文件夾和文件。此在iphone iphone中的Dropbox Api

代碼

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

這loadMetadata是DBRestClient.m class.I方法成功地在控制檯上打印JSON值

代碼是

- (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]; 
} 

我怎麼能使用這個結果值在我的視圖控制器中顯示在tableview中?

回答

2

獲取目錄的內容並將它們放入數組中。

- (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 */                       
      } 
     } 
    } 
} 

比加載陣列到您UITableView,你會任何其他NSArray/NSMutableArray

+0

Thanks..for回覆 – iProgrammer 2011-05-21 06:15:43