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
#import <Foundation/Foundation.h> | |
#import <objc/runtime.h> | |
#import <objc/objc.h> | |
#import <objc/message.h> | |
@implementation NSDecimalNumber (hack) | |
- (NSDecimalNumber *)decimalNumberByAdding_:(NSDecimalNumber *)decimalNumber | |
{ | |
return [[self decimalNumberByAdding_:decimalNumber] decimalNumberByAdding_:(self.integerValue == decimalNumber.integerValue == 1) ? decimalNumber : [NSDecimalNumber zero]]; |
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
#import <Foundation/Foundation.h> | |
@interface NSArray (objectForKeyedSubscript) | |
- (id)objectForKeyedSubscript:(id)key; | |
@end | |
@implementation NSArray (objectForKeyedSubscript) |
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
var mScript = function(text) { | |
// 正規表現パターンで付加する文字を決定する。 | |
var regs = { | |
"命令懇願": /[えけげせぜてでねへべぺめれ]よ?[。.]?$/, | |
"疑問惑困": /[??]$/, | |
"嬉輝喜怒哀楽": /[!!]$/, | |
"困惑": /[えけげせぜてでねへべぺめれ][んぬ][。.]?$/, | |
"飛旅": /旅行/, | |
"期待輝余裕勃": /.*/ | |
}; |
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
func printClasses() { | |
var count: CUnsignedInt = 0 | |
var clist = objc_copyClassList(&count) | |
for var i: CUnsignedInt = 0; i < count; i++ { | |
let c : AnyClass? = clist.memory | |
println(" #Class \(class_getName(c))") | |
printMethods(c) | |
clist = clist.succ() | |
} | |
} |
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 NSObject (forSwift) | |
- (id)__performSelector:(SEL)aSelector | |
{ | |
Method m = class_getInstanceMethod(self.class, aSelector); | |
const char *types = method_copyReturnType(m); | |
if (strcmp("v", types)) { | |
return [self performSelector:aSelector]; | |
} else { |
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
<key>NSExtension</key> | |
<dict> | |
<key>NSExtensionAttributes</key> | |
<dict> | |
<key>NSExtensionActivationRule</key> | |
<string>SUBQUERY (extensionItems, $extensionItem, SUBQUERY ($extensionItem.attachments, $attachment, NONE $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url" && ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url").@count > 0).@count > 0</string> | |
</dict> | |
<key>NSExtensionMainStoryboard</key> | |
<string>MainInterface</string> | |
<key>NSExtensionPointIdentifier</key> |
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
static void * swizzed(id self, SEL aSelector, void *arg,...) | |
{ | |
NSMethodSignature *signature = [self methodSignatureForSelector:aSelector]; | |
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; | |
[invocation retainArguments]; | |
[invocation setTarget:self]; | |
[invocation setSelector:aSelector]; | |
va_list argp; | |
va_start(argp, arg); | |
for (NSInteger idx = 2; idx < signature.numberOfArguments; idx++) { |
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
import Foundation | |
protocol Type { | |
typealias Value: Type | |
} | |
extension String: Type { | |
typealias Value = String | |
} |
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
//: Playground - noun: a place where people can play | |
import Foundation | |
import ObjectiveC | |
// Swiftで生成したクラスにMethodSwizzlingをすると失敗するデモ | |
class A: NSObject { | |
func zero() -> NSNumber { | |
return 0 | |
} |
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
extension Optional { | |
func _else(state: () -> Wrapped) -> Wrapped { | |
return self ?? state() | |
} | |
func _else_if(@autoclosure condition: () -> Bool, state: () -> Wrapped) -> Wrapped? { | |
return self ?? _if(condition(), state: state) | |
} | |
} |
OlderNewer