⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
This file contains hidden or 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
NSFileManager*fileMgr; | |
NSString*entry; | |
NSString*documentsDir; | |
NSDirectoryEnumerator*enumerator; | |
BOOL isDirectory; | |
// Create file manager | |
fileMgr =[NSFileManager defaultManager]; | |
// Path to documents directory | |
documentsDir =[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; | |
// Change to Documents directory[fileMgr changeCurrentDirectoryPath:documentsDir]; |
This file contains hidden or 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)displayErrorMessage:(NSString *)msg | |
{ | |
// Even shorter version, when the operant is the same as the "True" case: | |
NSString *msgFullString = [NSString stringWithFormat:@"Message: %@", msg ? : @"Unknown error"]; | |
NSLog(@"%@", msgFullString); | |
} |
This file contains hidden or 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)displayErrorMessage:(NSString *)msg | |
{ | |
// Even shorter version, when the operand is also the "True" case: | |
NSString *msgFullString = [NSString stringWithFormat:@"Message: %@", msg ? : @"Unknown error"]; | |
NSLog(@"%@", msgFullString); | |
} |
This file contains hidden or 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
/* | |
Core Data is great but automatic migrations can be tricky. Migrations can take a long time, which could | |
result in [your app being terminated](http://stackoverflow.com/questions/13333289/core-data-timeout-adding-persistent-store-on-application-launch) | |
if it is happening on the main thread during application launch. Performing migrations on a background | |
thread is also a [bad idea](http://stackoverflow.com/a/2866725/503916), meaning your application really | |
needs to be able to fully launch *without a Core Data stack whatsoever* in order to safely migrate. | |
This can be a huge change to make to an existing app. | |
If you're really only using Core Data as a cache, you don't actually *need* to perform a migration. | |
Simply check if the existing store is compatible with your managed object model and if so, delete |
This file contains hidden or 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
@interface UntoggleableSwitch : UISwitch | |
@end |
This file contains hidden or 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
/* | |
Getting a locale to match the user's language preference | |
*/ | |
// You’d think you could just use: | |
[NSLocale currentLocale]; | |
// But you’d be wrong. Instead, go with: | |
[[NSLocale alloc] initWithLocaleIdentifier:[NSLocale preferredLanguages][0]]; |
This file contains hidden or 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 stringRemoveNonAlphaNum(char *str) | |
{ | |
unsigned long i = 0; | |
unsigned long j = 0; | |
char c; | |
while ((c = str[i++]) != '\0') | |
{ | |
if (isalnum(c)) | |
{ |
This file contains hidden or 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 stringReverse(char *str) | |
{ | |
char *p1, *p2; | |
if (!str || !*str) | |
{ | |
NSLog(@"No string passed into reverse function."); | |
} | |
for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2) | |
{ |
This file contains hidden or 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
# Here is a Bookmarklet for running the script using the current page's URL | |
# as input: javascript:(function()%7Bif(document.location.href.indexOf('http')===0)document.location.href='pythonista://marky?action=run&argv='+document.location.href;%7D)(); | |
import clipboard | |
import urllib2 | |
import webbrowser | |
def markdownify(clipstring): | |
marky = 'http://heckyesmarkdown.com/go/?u=' |