Skip to content

Instantly share code, notes, and snippets.

View sendoa's full-sized avatar

Sendoa Portuondo sendoa

View GitHub Profile
@sendoa
sendoa / archivo.m
Created November 27, 2012 14:56
Modern enum en Objective-C
// http://objective-c.es/modern-objective-c-enum/
// http://nshipster.com/ns_enum-ns_options/
typedef NS_ENUM(NSUInteger, GBDaysOfWeek) {
GBSunday,
GBMonday,
GBTuesday,
GBWednesday,
GBThursday,
GBFriday,
@sendoa
sendoa / gist:4272498
Created December 12, 2012 23:04
Eliminar elementos duplicados de un NSArray
// Eliminar elementos duplicados en un NSArray
NSArray *cleanedArray = [[NSSet setWithArray:dates] allObjects];
@sendoa
sendoa / gist:4320773
Created December 17, 2012 18:42 — forked from twobitlabs/gist:4226365
Ejemplos de declaraciones de blocks
// http://cocoawithlove.com/2009/10/ugly-side-of-blocks-explicit.html has a nice breakdown of the syntax--it helps to think of the ^ as similar to a pointer dereference symbol *
// block typedef:
typedef void(^Block)();
typedef void(^ConditionalBlock)(BOOL);
typedef NSString*(^BlockThatReturnsString)();
typedef NSString*(^ConditionalBlockThatReturnsString)(BOOL);
// block property with typedef:
@sendoa
sendoa / cs_xproj_validate.sh
Created December 20, 2012 14:00 — forked from rjstelling/cs_xproj_validate.sh
Script que comprueba si el archivo de proyecto tiene la config de CODE_SIGN_IDENTITY corrupta. http://stackoverflow.com/q/13962341/89035
# /bin/bash
#Usage: $ ./cs_xproj_validate.sh path/to/xcode/project/file/theproject.xcodeproj
#More info: http://stackoverflow.com/q/13962341/89035
PROJECT_FILE="$1/project.pbxproj"
PREVIOUS_LINE=-1
for LINE in `cat "$PROJECT_FILE" | grep -n CODE_SIGN_IDENTITY | grep -o -E '^([0-9]*)'`
@sendoa
sendoa / UIUtil.h
Created January 24, 2013 16:08
Obtenido de http://www.integratingstuff.com/2012/02/25/some-ios-development-tips/ Macro para programar apps universales y ejemplo
#ifdef UI_USER_INTERFACE_IDIOM()
#define IS_IPAD() (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#else
#define IS_IPAD() (false)
#endif
#import "UiUtil.h"
@implementation UiUtil
@sendoa
sendoa / run-script.sh
Last active December 18, 2015 02:39
This script will auto-increment your Xcode project's build number for every build (debug & release). It will also increment the third position of a semantic formatted version string only for release builds: Examples: Build number: from 123 to 124 Version string: from 1.2.5 to 1.2.6
# This script will auto-increment your Xcode project's build number for every build (debug & release).
# It will also increment the third position of a semantic formatted version string only for release builds
#
# Examples:
# Buil number (CFBundleVersion): from 123 to 124
# Version string (CFBundleShortVersionString): from 1.2.5 to 1.2.6
#
# 1. Select your Target in Xcode
# 2. Select "Build Phases" Tab
# 3. Select "Add Build Phase" -> "Add Run Script"
@sendoa
sendoa / gist:5916356
Created July 3, 2013 08:28 — forked from JaviSoto/gist:5906004
Set the designated initializer at compile time
#define MSDesignatedInitializer(__SEL__) __attribute__((unavailable("Invoke the designated initializer `" # __SEL__ "` instead.")))
// Sample usage:
- (id)initWithObject:(id)object;
- (id)init MSDesignatedInitializer(initWithObject:); // <- This even gets auto-complete.
// Now calling init on this class would throw a warning.
@sendoa
sendoa / ejemplo.m
Created July 4, 2013 10:04
UILabel con URL clicable
yourTextView.editable = NO;
yourTextView.dataDetectorTypes = UIDataDetectorTypeAll;
@sendoa
sendoa / SDWebImageDecoder.m
Created July 4, 2013 10:06
Force image decompression
// https://github.com/rs/SDWebImage
// https://github.com/rs/SDWebImage/wiki/How-is-SDWebImage-better-than-X%3F
#import "SDWebImageDecoder.h"
@implementation UIImage (ForceDecode)
+ (UIImage *)decodedImageWithImage:(UIImage *)image
{
CGImageRef imageRef = image.CGImage;
@sendoa
sendoa / Dlog.h
Created July 9, 2013 20:33
NSLog and NSAssert substitution macros based on the ones from Marcus Zarra http://www.cimgf.com/2010/05/02/my-current-prefix-pch-file/ When the app runs on "Release" mode, assertions are linked to TestFlight checkpoints. I always name assertion type checkpoints with "ASSERTION" prefix. Example: Alog(@"ASSERTION_NON_PARSEABLE_ITEM_DATA_RECEIVED");
#ifdef DEBUG
#define DLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
#define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__]
#else
#define DLog(...) do { } while (0)
#define ALog(...) [TestFlight passCheckpoint:[NSString stringWithFormat:__VA_ARGS__]]
#ifndef NS_BLOCK_ASSERTIONS
#define NS_BLOCK_ASSERTIONS
#endif
#endif