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
// 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, |
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
// Eliminar elementos duplicados en un NSArray | |
NSArray *cleanedArray = [[NSSet setWithArray:dates] allObjects]; |
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
// 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: |
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
# /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]*)'` |
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
#ifdef UI_USER_INTERFACE_IDIOM() | |
#define IS_IPAD() (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | |
#else | |
#define IS_IPAD() (false) | |
#endif | |
#import "UiUtil.h" | |
@implementation UiUtil |
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
# 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" |
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
#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. |
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
yourTextView.editable = NO; | |
yourTextView.dataDetectorTypes = UIDataDetectorTypeAll; |
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
// 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; |
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
#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 |