This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)reloadData { | |
[self.refreshControl beginRefreshing]; | |
//chamada em background | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
//requisição dos dados do servidor | |
NSError *err = nil; | |
NSArray *json = nil; | |
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:kURL]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//DataManager.h | |
#import <Foundation/Foundation.h> | |
typedef void(^DataManagerDidGetData)(NSArray *json); | |
typedef void(^DataManagerDidError)(NSError *error); | |
@interface DataManager : NSObject | |
- (void)getData:(DataManagerDidGetData)complete error:(DataManagerDidError)error; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)reloadData { | |
[self.refreshControl beginRefreshing]; | |
[self.dataManager getData:^(NSArray *json) { | |
//converte os objetos do servidor no nosso modelo de objetos | |
NSMutableArray *items = [NSMutableArray array]; | |
for (NSDictionary *jsonItem in json) { | |
TableData *item = [[TableData alloc] initWithJSON:jsonItem]; | |
item.position = [NSNumber numberWithInteger:[json indexOfObject:jsonItem]+1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TableDataSource.h | |
#import <Foundation/Foundation.h> | |
#import <UIKit/UIKit.h> | |
@interface TableDataSource : NSObject<UITableViewDataSource> | |
@property (nonatomic, strong) NSArray *data; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TableDelegate.h | |
#import <Foundation/Foundation.h> | |
#import <UIKit/UIKit.h> | |
@interface TableDelegate : UIControl <UITableViewDelegate> | |
@property (nonatomic, strong) NSArray *data; | |
@property (readonly) id selectedData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TableCoordinator.h | |
#import <Foundation/Foundation.h> | |
#import <UIKit/UIKit.h> | |
@interface TableCoordinator : NSObject | |
@property (nonatomic, strong) IBOutlet UITableView *tableView; | |
- (void)reloadData:(NSArray *)data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "TableDelegate.h" | |
//adicionar antes do último @end | |
#pragma mark - IBActions - | |
- (IBAction)itemPressed:(TableDelegate*)sender { | |
TableData *data = sender.selectedData; | |
UIAlertController *alert = [UIAlertController alertControllerWithTitle:data.title message: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @Credits: paiego | |
* @Description: edited paiego's code to adapt to my use (error animation feedback) | |
* @See: http://stackoverflow.com/a/9753948/4075379 | |
*/ | |
- (CAAnimation *)shakeAnimation { | |
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; | |
CGFloat wobbleAngle = 0.06f; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<code_scheme name="Default" version="173"> | |
<option name="RIGHT_MARGIN" value="100" /> | |
<AndroidXmlCodeStyleSettings> | |
<option name="USE_CUSTOM_SETTINGS" value="true" /> | |
</AndroidXmlCodeStyleSettings> | |
<JavaCodeStyleSettings> | |
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" /> | |
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" /> | |
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND"> | |
<value /> |
OlderNewer