Skip to content

Instantly share code, notes, and snippets.

View daniel-rueda's full-sized avatar

Daniel Rueda Jimenez daniel-rueda

View GitHub Profile
@daniel-rueda
daniel-rueda / CertificatePinningURLSessionDelegate.swift
Last active April 5, 2024 05:52
Certificate and Public Key Pinning for URLSession using Swift
// Based on https://code.tutsplus.com/articles/securing-communications-on-ios--cms-28529
import Foundation
import Security
struct Certificate {
let certificate: SecCertificate
let data: Data
}
// Crear un navigation controller usando un XIB
// Primero se debe crear el view controller inicial (root view controller)
// MyViewController cuenta con un archivo xib
MyViewController *viewController = [[MyViewController alloc] init];
// Se crear el navigationController para presentar el viewController
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
@daniel-rueda
daniel-rueda / gist:3291397
Created August 8, 2012 02:04 — forked from christianroman/gist:3248993
Check if UITextFields are empty using Objective-C
BOOL emptyTextFields(id toCompare,...)
{
va_list args;
va_start(args, toCompare);
id value = nil;
BOOL match = NO;
while ( (value = va_arg(args,id)) ){
if( [toCompare isKindOfClass:[NSString class]] && [value isKindOfClass:[UITextField class]] ){
@daniel-rueda
daniel-rueda / gist:1512096
Created December 22, 2011 22:18
Cambios en DataModel
// Agrega metodo para mapear lo que recibes de la API con atributos de una clase
- (RKManagedObjectMapping *)objectMappingForPublishedID
{
RKManagedObjectMapping *objectMapping = [RKManagedObjectMapping mappingForEntityWithName:@"Publication"];
[objectMapping mapKeyPath:@"account"
toAttribute:@"account"];
[objectMapping mapKeyPath:@"status_id"
toAttribute:@"statusID"];
return objectMapping;
}
@daniel-rueda
daniel-rueda / gist:1472792
Created December 13, 2011 16:30
Add tags to AlertView
// Crear alerta, asignar delegate y tag
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"You must register a Facebook account first"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK"];
alert.tag = 101;
[alert show];
[alert release];
@daniel-rueda
daniel-rueda / MySingleton.m
Created June 23, 2011 19:32
Singleton instance
#import "MySingleton.h"
@implementation MySingleton
// Referencia al singleton
static MySingleton *_sharedSingleton = nil;
// Regresa la instancia singleton
+ (MySingleton *)sharedSingleton
{