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
void objc_setAssociatedObject ( id object, const void *key, id value, objc_AssociationPolicy policy ); | |
// object = usually 'self'. This is the object you want to associate a key and value with. | |
// key = the key you want to associate the object with | |
// value = the value you want to associate with the key | |
// objc_AssociationPolicy is one of the below: | |
enum { | |
OBJC_ASSOCIATION_ASSIGN = 0, | |
OBJC_ASSOCIATION_RETAIN_NONATOMIC = 1, |
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
--- | |
Language: Cpp | |
BasedOnStyle: WebKit | |
# AccessModifierOffset: -4 | |
# ConstructorInitializerIndentWidth: 4 | |
# AlignEscapedNewlinesLeft: false | |
# AlignTrailingComments: false | |
# AllowAllParametersOfDeclarationOnNextLine: true | |
# AllowShortBlocksOnASingleLine: false | |
# AllowShortCaseLabelsOnASingleLine: false |
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
@implementation EVCSomeClass | |
+(EVCSomeClass *)shared { | |
static EVCSomeClass *shared = nil; | |
if( !shared ) { | |
shared = [EVCSomeClass new]; | |
} | |
return shared; |
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
@implementation EVCSomeClass | |
+(EVCSomeClass *)shared { | |
static EVCSomeClass *shared = nil; | |
// synchronizes by locking on the Class EVCSomeClass | |
@synchronized([EVCSomeClass class]) { | |
shared = [EVCSomeClass new]; | |
} | |
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
@implementation EVCSomeClass | |
+(EVCSomeClass *)shared { | |
static EVCSomeClass *shared = nil; | |
// dispatch_once_t is typedef'd to a long | |
static dispatch_once_t pred; | |
// this block is executed synchronously, and only one time ever for the given predicate | |
dispatch_once(&pred, ^{ |
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
// the block that's passed in needs to return an object | |
#define DEFINE_SHARED_INSTANCE_USING_BLOCK(block) \ | |
static dispatch_once_t pred = 0; \ | |
__strong static id _sharedObject = nil; \ | |
dispatch_once(&pred, ^{ _sharedObject = block(); }); \ | |
return _sharedObject; |
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
// | |
// BJMSearchBar.h | |
// | |
// Created by Vinayak Ram on 9/8/15. | |
// | |
#import <UIKit/UIKit.h> | |
@interface BJMSearchBar : UISearchBar |
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 | |
find . -name '*.strings' -print | egrep -v 'Pods' | zip source -@ | |
# Break it down: | |
# | |
# Find all files with file name ending with .strings | |
# find . -name '*.strings' -print | |
# | |
# Search for all lines that don't have 'Pods' in it (the -v means invert) |
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
/* | |
* Downloading files using AFNetworking is not a 1-step process, but it's still pretty easy. | |
* | |
* NOTE: If you're downloading a file from S3, make sure to set the proper Content-Type. For example, | |
* a zip file should ideally have the content type of application/zip. | |
* | |
* Inspired by various sources online. | |
*/ | |
#pragma mark - Downloading Files |
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 | |
# find all .m files and pump it through genstrings, outputting it to en.lproj/Localizable.strings | |
find . -name '*.m' | xargs genstrings -o en.lproj |
OlderNewer