Skip to content

Instantly share code, notes, and snippets.

View thiagolioy's full-sized avatar

Thiago Lioy thiagolioy

View GitHub Profile
@thiagolioy
thiagolioy / ApiClient.h
Last active August 29, 2015 14:22
ViewController Tests Example with Specta Expecta OCMock
typedef void (^CompletionBlock)(NSArray *results);
@interface ApiClient : NSObject
-(void)fetchCatalog:(CompletionBlock)block;
@end
@implementation ApiClient
@thiagolioy
thiagolioy / Fastfile.rb
Last active August 29, 2015 14:22
Fastfile with tests , coverage and deploy
fastlane_version "1.0.2"
default_platform :ios
platform :ios do
before_all do
cocoapods
@thiagolioy
thiagolioy / SessionManagerSpec.m
Created June 11, 2015 13:59
How to use Specta, Expecta and OCMock . With ViewControllers and Helper|Utility Classes
#import <UIKit/UIKit.h>
#import <Specta.h>
#import <Expecta.h>
#import <OCMock.h>
#import "SessionManager.h"
SpecBegin(SessionManagerSpec)
@thiagolioy
thiagolioy / EnvironmentUtil.m
Created June 15, 2015 17:16
DBEnvironmentConfiguration example
#import "EnvironmentUtil.h"
#import <DBEnvironmentConfiguration/DBEnvironmentConfiguration.h>
@implementation EnvironmentUtil
+(void)setupEnvironmentMappings{
[DBEnvironmentConfiguration setEnvironmentMapping:@{
[NSNumber numberWithInt:DBBuildTypeSimulator] : @"Staging",
[NSNumber numberWithInt:DBBuildTypeDebug] : @"Staging",
@thiagolioy
thiagolioy / mocking_view_controller_methods.m
Last active August 29, 2015 14:24
Testing Mocking blocks response
__block HomeViewController *vc;
beforeAll(^{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *controller = [mainStoryboard instantiateViewControllerWithIdentifier:@"HomeViewController"];
vc = (HomeViewController *)(controller);
[vc view];
});
+(NSDictionary*)parse:(NSDictionary*)dc{
NSMutableDictionary *mutDc = [NSMutableDictionary dictionaryWithDictionary:dc];
for(NSString *key in mutDc.allKeys){
NSString *value = [mutDc objectForKey:key];
if([value isEqualToString:@"true"])
[mutDc setObject:@YES forKey:key];
else if([value isEqualToString:@"false"])
[mutDc setObject:@NO forKey:key];
}
@thiagolioy
thiagolioy / parse.m
Created December 6, 2015 15:06
Bricks! Mantle parse
@interface BKBaseMantleObj : MTLModel<MTLJSONSerializing>
+ (NSDictionary *)JSONKeyPathsByPropertyKey;
+(instancetype)parse:(NSDictionary*)dc error:(NSError**)error;
-(NSDictionary*)asDictError:(NSError**)error;
@end
@interface BKBaseMantleObj (Collections)
import Foundation
import Moya
import CryptoSwift
import Dollar
import Keys
fileprivate struct MarvelAPIConfig {
fileprivate static let keys = MarvelKeys()
static let privatekey = keys.marvelPrivateKey()!
static let apikey = keys.marvelApiKey()!
@thiagolioy
thiagolioy / Podfile
Created November 21, 2016 10:55
MarvelApp podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'Marvel' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
plugin 'cocoapods-keys', {
:project => "Marvel",
:keys => [
import Foundation
import Moya
import RxSwift
import ObjectMapper
import Moya_ObjectMapper
extension Response {
func removeAPIWrappers() -> Response {
guard let json = try? self.mapJSON() as? Dictionary<String, AnyObject>,
let results = json?["data"]?["results"] ?? [],