Skip to content

Instantly share code, notes, and snippets.

View jlcampana's full-sized avatar
:octocat:
emu emu emu...

Jose Luis Campaña jlcampana

:octocat:
emu emu emu...
View GitHub Profile
@jlcampana
jlcampana / runtime_check_ios5
Created January 20, 2012 10:18
Runtime check for iOS5
+(BOOL)deviceIsRunningOS5
{
UIScreen *s = [UIScreen mainScreen];
return [s respondsToSelector:@selector(brightness)];
}
@jlcampana
jlcampana / gist:3245376
Created August 3, 2012 07:26
Network activity
_netRequests--;
if(_netRequests == 0) [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
@jlcampana
jlcampana / gist:3246089
Created August 3, 2012 08:57
Crear identificativo único para el dispositivo
- (NSString *)createUUID
{
// Create universally unique identifier (object)
CFUUIDRef uuidObject = CFUUIDCreate(kCFAllocatorDefault);
// Get the string representation of CFUUID object.
NSString *uuidStr = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuidObject) autorelease];
// If needed, here is how to get a representation in bytes, returned as a structure
// typedef struct {
@jlcampana
jlcampana / gist:3246356
Created August 3, 2012 09:49
Dismiss keyboard
[self.view endEditing:YES];
@jlcampana
jlcampana / ASI HTTP Request + JSON Sample
Created August 7, 2012 13:02
ASI HTTP Request + JSON Sample
ASIHTTPRequest *req = [ASIHTTPRequest requestWithURL:URL];
req.delegate = self;
req.userInfo = [NSDictionary dictionaryWithObject:@"initialRequest" forKey:@"type"];
NSData *body = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
[req appendPostData:body];
[req startSynchronous];
@jlcampana
jlcampana / gist:3293336
Created August 8, 2012 08:07
Rounded navigationBar
CALayer *capa = [self.navigationController navigationBar].layer;
[capa setShadowColor: [[UIColor blackColor] CGColor]];
[capa setShadowOpacity:0.85f];
[capa setShadowOffset: CGSizeMake(0.0f, 1.5f)];
[capa setShadowRadius:2.0f];
[capa setShouldRasterize:YES];
//Round
CGRect bounds = capa.bounds;
@jlcampana
jlcampana / gist:3294395
Created August 8, 2012 11:31
ARC Delegate (protocolo)
//.h
@protocol XXXXXXDelegate <NSObject>
@optional
@end
@property (nonatomic, weak) id <XXXXXXDelegate> delegate;
@jlcampana
jlcampana / gist:3303027
Created August 9, 2012 10:19
Reverse array
NSArray* reversedArray = [[startArray reverseObjectEnumerator] allObjects];
@jlcampana
jlcampana / CWLSynthesizeSingleton.h
Created August 10, 2012 09:44
Clase para crear singletons
//
// CWLSynthesizeSingleton.h
// CocoaWithLove
//
// Created by Matt Gallagher on 2011/08/23.
// Copyright (c) 2011 Matt Gallagher. All rights reserved.
//
// Permission is given to use this source code file, free of charge, in any
// project, commercial or otherwise, entirely at your risk, with the condition
// that any redistribution (in part or whole) of source code must retain
@jlcampana
jlcampana / gist:3313280
Created August 10, 2012 10:37
JSON (NSDictionary) a String
NSError *error;
NSData *body = [NSJSONSerialization dataWithJSONObject:payJSON options:NSJSONWritingPrettyPrinted error:&error];
NSString *jsonString = [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding];