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
NSArray *reversedArray = array.reverseObjectEnumerator.allObjects; |
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
#import "objc/runtime.h" | |
Class NSClassFromString(NSString *aClassName) { | |
NSLog(@"%@", aClassName); | |
id class = objc_getClass(aClassName.UTF8String); | |
return class; | |
} |
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
tell application "Final Cut Pro" to activate | |
tell application "System Events" | |
if UI elements enabled is false then | |
keystroke "]" using shift down | |
else | |
tell process "Final Cut Pro" | |
--click menu item "In to Out" of menu 1 of menu item "Play" of menu "Mark" of menu bar 1 | |
click menu item 1 of menu 1 of menu item 21 of menu 6 of menu bar 1 | |
end tell | |
end if |
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
@implementation NSUserDefaults (RegisterDefault) | |
- (void)registerDefaultObject:(id)value forKey:(NSString *)defaultName { | |
NSMutableDictionary *mDict = [self volatileDomainForName:NSRegistrationDomain].mutableCopy; | |
[mDict setObject:value forKey:defaultName]; | |
[self setVolatileDomain:mDict forName:NSRegistrationDomain]; | |
} | |
@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
// select language from application's localizations | |
NSBundle *mainBundle = [NSBundle mainBundle]; | |
NSArray *localizations = mainBundle.localizations; | |
NSString *localization = localizations.lastObject; | |
// search bundle contains Localizable.string | |
NSURL *URL = [mainBundle URLForResource:@"Localizable" withExtension:@"strings" subdirectory:nil localization:localization]; | |
NSBundle *bundle = [NSBundle bundleWithURL:URL.URLByDeletingLastPathComponent]; | |
// get localized string from bundle |
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
// UIFontDescriptor on iOS 7 or later | |
NSDictionary *traitsAttributes = @{UIFontSymbolicTrait: @(UIFontDescriptorTraitMonoSpace)}; | |
NSDictionary *fontAttributes = @{UIFontDescriptorTraitsAttribute: traitsAttributes}; | |
UIFontDescriptor *fontDescriptor = [UIFontDescriptor fontDescriptorWithFontAttributes:fontAttributes]; | |
NSArray *array = [fontDescriptor matchingFontDescriptorsWithMandatoryKeys:nil]; | |
for (UIFontDescriptor *descriptor in array) { | |
NSLog(@"%@", descriptor.postscriptName); | |
// NSLog(@"%@", [descriptor objectForKey:UIFontDescriptorNameAttribute]); | |
// NSLog(@"%@", [descriptor objectForKey:UIFontDescriptorVisibleNameAttribute]); |
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
ObjC.import('Cocoa') | |
//var array = $.NSArray.arrayWithObjects($('jp'), $('us'), $('es'), $('ru')); | |
var array = $(['jp', 'us', 'es', 'ru']); | |
for (var i=0; i<array.count; i++) { | |
var string = array.objectAtIndex(i); | |
var URLString = $.NSString.stringWithFormat('http://store.apple.com/%@/product/MB110CH/B/', string); | |
var URL = $.NSURL.URLWithString(URLString) | |
$.NSWorkspace.sharedWorkspace.openURL(URL) | |
} |
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
// NSAssert can be used in method | |
- (void)method | |
{ | |
NSAssert(false, @"message"); | |
} | |
// NSCAssert can be used in function | |
void func() | |
{ | |
NSCAssert(false, @"message"); |
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
+ (BOOL)containsOnlyDecimalNumbers1:(NSString *)string | |
{ | |
NSCharacterSet *characterSet = [NSCharacterSet characterSetWithCharactersInString:string]; | |
return [[NSCharacterSet decimalDigitCharacterSet] isSupersetOfSet:characterSet]; | |
} | |
+ (BOOL)containsOnlyDecimalNumbers2:(NSString *)string | |
{ | |
NSCharacterSet *characterSet = [NSCharacterSet decimalDigitCharacterSet].invertedSet; | |
return [string rangeOfCharacterFromSet:characterSet].length == 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
#import <objc/runtime.h> | |
void PrintMethodList(Class cls) { | |
printf("// Method List of %s\n", class_getName(cls)); | |
unsigned int outCount; | |
Method *methodList = class_copyMethodList(cls, &outCount); | |
for (unsigned int i=0; i<outCount; i++) { | |
Method m = methodList[i]; | |
SEL sel = method_getName(m); | |
printf("%s\n", sel_getName(sel)); |
OlderNewer