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
self.myDisposable = provider.mySignal.subscribeNext({(someObject) -> RACSignal! in | |
// do anything you want | |
return nil | |
}) | |
// if you want to unsubscribe, then | |
self.myDisposable.dispose() | |
// this is like we usually nilify delegate, but such explicit memory management is always a bad thing | |
// there should be some better practice I believe |
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
let options = NSStringDrawingOptions(rawValue: | |
NSStringDrawingOptions.UsesLineFragmentOrigin.rawValue | NSStringDrawingOptions.UsesFontLeading.rawValue | |
) |
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
if let value: NSString = self.filterSender { // Casted to NSString | |
let sender = value.cStringUsingEncoding(NSUTF8StringEncoding) // NSString.cStringUsingEncoding() | |
asl_set_query(query, ASL_KEY_SENDER, sender, UInt32(ASL_QUERY_OP_EQUAL | ASL_QUERY_OP_SUBSTRING)) | |
} |
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 nextResponse = some_api(param) | |
while (UnsafePointer<Int8>.null != nextResponse) { | |
// do something with response, then | |
nextResponse = some_api(param) | |
} |
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 dataTypeRef :Unmanaged<AnyObject>? | |
let status: OSStatus = SecItemCopyMatching(query, &dataTypeRef) | |
if status == noErr { | |
return (dataTypeRef!.takeRetainedValue() as NSData) | |
} |
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
#!/usr/bin/env ruby | |
# gist: https://gist.github.com/akisute/1976286e8cee7703dd7d | |
# | |
# Needs QIF and OFX support | |
# QIF gem - https://rubygems.org/gems/qif | |
# OFX gem - https://rubygems.org/gems/ofx | |
# - https://rubygems.org/gems/ofx-parser | |
# QIF format doc - http://en.wikipedia.org/wiki/Quicken_Interchange_Format | |
# OFX format doc - http://www.exactsoftware.com/docs/DocView.aspx?DocumentID=%7B6e02f9a5-ee40-4d2f-b8ea-4bee57825907%7D |
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
- (NSString *)text6Compatible | |
{ | |
return self.text; | |
} | |
- (void)setText6Compatible:(NSString *)text6Compatible | |
{ | |
self.text = text6Compatible; | |
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(7)) { |
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
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) { | |
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIRemoteNotificationTypeSound) categories:nil]; | |
[[UIApplication sharedApplication] registerUserNotificationSettings:settings]; // Asks users for authorization | |
[[UIApplication sharedApplication] registerForRemoteNotifications]; | |
} else { | |
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)]; // Asks users for authorization | |
} |
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
// NSManagedObjectを継承してさえいれば @objc はもう不要です。 | |
// 古いバージョンでは必要だったことがありました。 | |
class MyEntity: NSManagedObject { | |
// @dynamicの代わりに@NSManagedを使います | |
@NSManaged var name: String | |
// IntじゃなくてNSNumberを使います | |
@NSManaged var count: NSNumber | |
// BoolじゃなくてNSNumberを使います | |
@NSManaged var isExported: NSNumber |
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 NSManagedObject { | |
public class var entityName:String { | |
get { | |
// NSManagedObject及びそのサブクラスはObjective-Cクラスなので、 | |
// NSStringFromClass(self)の結果が素直な名前になります。 | |
// 具体的にはモジュール名.クラス名を返します。 | |
// ここでは.でセパレートしてクラス名だけを返すようにしています。 | |
return NSStringFromClass(self).componentsSeparatedByString(".").last! | |
} |