Pod fo SWCells

This commit is contained in:
2016-03-31 15:57:13 +02:00
parent 1abf1a0c2a
commit 3628451317
70 changed files with 4109 additions and 18 deletions
+2 -1
View File
@@ -29,7 +29,8 @@
- (void)downloadFromDropbox:(NSArray *)files;
- (void)uploadToDropbox:(NSArray *)files;
- (NSArray *)contentsOfPath:(NSString *)path;
- (void)contentsOfPath:(NSString *)path
completion:(void (^)(NSArray *data))handler;
#pragma mark - Other methods
+16 -15
View File
@@ -96,11 +96,11 @@
#pragma mark - File and directory operations
/**
* Pass nil as path for root dir
* @return Content of directory at path or nil if error
* @param completion executed after completion
*/
// !!!: Cannot be asynchronous
// TODO: Alert on error
- (NSArray *)contentsOfPath:(NSString *)path
- (void)contentsOfPath:(NSString *)path
completion:(void (^)(NSArray *data))handler
{
if (path == nil) {
@@ -132,18 +132,19 @@
[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
temp = [temp stringByReplacingOccurrencesOfString:@"\\/" withString:@"/"];
request.HTTPBody = [temp dataUsingEncoding:NSASCIIStringEncoding];
NSURLResponse *response = nil;
NSError *error = nil;
id dataOut =
[self parseJSON:[NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error]];
if ([dataOut isKindOfClass:[NSDictionary class]]) {
return [dataOut valueForKey:@"entries"];
}
else {
return nil;
}
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response,
NSData *data, NSError *error) {
data =
[NSJSONSerialization JSONObjectWithData:data
options:0
error:nil];
if ([data isKindOfClass:[NSDictionary class]]) {
handler([data valueForKey:@"entries"]);
}
}];
}
// TODO: Alert on error
+1
View File
@@ -6,6 +6,7 @@
// Copyright © 2016 Kilian Hofmann. All rights reserved.
//
#import "AppDelegate.h"
#import "SharedDeclerations.h"
#import "ViewController.h"
#import <UIKit/UIKit.h>
+37 -1
View File
@@ -32,6 +32,27 @@
[NSPredicate predicateWithFormat:@"NOT (SELF BEGINSWITH %@)",
@"."]] mutableCopy];
}
if ([self.title isEqualToString:@"Download"]) {
DropboxV2ObjC *dbClient =
((AppDelegate *)[UIApplication sharedApplication].delegate)
.dbClient;
[dbClient
contentsOfPath:nil
completion:^(NSArray *data) {
NSMutableArray *temp = [[NSMutableArray alloc] init];
for (NSDictionary *dict in data) {
[temp addObject:[dict valueForKey:@"name"]];
}
_dataSource = [[temp
filteredArrayUsingPredicate:
[NSPredicate
predicateWithFormat:@"NOT (SELF BEGINSWITH %@)",
@"."]] mutableCopy];
[self.tableView reloadData];
}];
}
}
#pragma mark - Table view data source
@@ -61,11 +82,25 @@
.row]]];
cell.textLabel.text = [data valueForKey:@"MENU@LSKR1"];
}
if ([self.title isEqualToString:@"Download"]) {
cell.textLabel.text = _dataSource[indexPath.row];
}
return cell;
}
#pragma mark - Table view editing action
- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Detemine if it's in editing mode
if ([self.title isEqualToString:@"Manage"]) {
return UITableViewCellEditingStyleDelete;
}
return UITableViewCellEditingStyleNone;
}
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
@@ -82,7 +117,8 @@
withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the
// Create a new instance of the appropriate class, insert it into
// the
// array, and add a new row to the table view
}
}
+4 -1
View File
@@ -93,7 +93,10 @@
{
DropboxV2ObjC *dbClient =
((AppDelegate *)[UIApplication sharedApplication].delegate).dbClient;
NSLog(@"%@", [dbClient contentsOfPath:nil]);
[dbClient contentsOfPath:nil
completion:^(NSArray *data) {
NSLog(@"%@", data);
}];
[dbClient uploadToDropbox:@[ @"EDDFEDDM001" ]];
}