보관 용 파일을 UITableView에로드하려고하는데 표시되지 않습니다. dropbox.com에 내 앱을 등록하고 내 앱에서 세션 대리인을 구현하는 모든 단계를 수행했습니다. 여기 내 코드는 누구나 저에게 뭐가 잘못 됐는지 말해 줄 수 있습니까? 임 꽤 확신 내가 모든 것을 올바르게 선언했지만 문제는 찾을 수 없습니다. 또한 NSLog를 추가하고 파일을 기록하기 때문에 연결 문제가 아니라는 것을 알고 있습니다.보관 용 파일을 UITableView에 추가
#import <UIKit/UIKit.h>
#import <DropboxSDK/DropboxSDK.h>
@interface testViewController : UITableViewController <DBRestClientDelegate>
{
DBRestClient *restClient;
NSMutableArray *dropboxURLs;
}
@end
#import "testViewController.h"
@interface testViewController()
@end
@implementation testViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (DBRestClient *)restClient {
if (!restClient) {
restClient =
[[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
restClient.delegate = self;
}
return restClient;
}
- (void)viewDidLoad
{
[super viewDidLoad];
dropboxURLs = [[NSMutableArray alloc] init];
[[self restClient] loadMetadata:@"/"];
}
- (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata {
if (metadata.isDirectory) {
for (DBMetadata *file in metadata.contents) {
if (!file.isDirectory)
{
NSLog(@"%@", file.filename);
[dropboxURLs addObject:file.filename];
}
}
}
}
- (void)restClient:(DBRestClient *)client
loadMetadataFailedWithError:(NSError *)error {
NSLog(@"Error loading metadata: %@", error);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return dropboxURLs.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"FileCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [dropboxURLs objectAtIndex:indexPath.row];
return cell;
}
@end
당신은 당신이 파일을 기록했다? dropBoxURL을 로그하여 로그에 아무것도 없는지 확인 했습니까? 오류 메시지에서 배열이 비어있는 것으로 나타납니다. – rdelmar
@rdelmar 안녕하세요, 내가 배열에 추가하기 전에 바로 파일을 기록 : NSLog (@ "% @", file.filename); [dropboxURLs addObject : file.filename]; – Cristian
numberOfRowsInSection 메서드에서 dropboxURLs.count를 반환하여 반환하는 내용을 확인하십시오. – rdelmar