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
public class MainActivity extends Activity { | |
@InjectView(R.id.text) | |
TextView mTextView; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
final Object activity = this; |
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
- (BFTask *)loadSomeDataWithToken:(TaskToken *)token | |
{ | |
BFTask *getSomeDataTask; | |
BFTask *getOtherDataTask; | |
getSomeDataTask = [[APIClient sharedClient] withToken:token executeAPI:^BFTask *(APIClient *client) { | |
return [[client getSomeDataWithParameters:@{}] continueWithSuccessBlock:^id(BFTask *task) { | |
// TODO: do something | |
return task; | |
}]; | |
}]; |
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
/* | |
WARNING: PRIVATE API CALLS | |
WARNING: FORCEFUL MEMORY MANAGEMENT | |
highly recommend to avoid using this code | |
*/ | |
- (void)exitFullScreenVideo:(BOOL)animated completion:(void (^)(void))completion | |
{ | |
/* | |
iOS 6~7の場合 | |
本ViewControllerの上にMPInlineVideoFullscreenViewControllerがfullscreen modalで表示されるような挙動になるので |
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)exitFullScreenVideo | |
{ | |
// Works in iOS, not sure in OS X | |
[self.webView stringByEvaluatingJavaScriptFromString:@"Array.prototype.forEach.call(document.getElementsByTagName('video'),function(v){v.webkitExitFullscreen();});"]; | |
// Didn't work in iOS, works in OS X | |
[self.webView stringByEvaluatingJavaScriptFromString:@"if(document.webkitFullscreenElement){document.webkitExitFullscreen();}"]; | |
} |
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
// Objective-C | |
@interface Document: NSObject | |
@property (nonatomic, copy) NSArray *notes; | |
@property (nonatomic, readonly) RACSignal *notesUpdatedSignal; | |
@end | |
@implementation Document | |
- (RACSignal *)notesUpdatedSignal | |
{ | |
// In Objective-C, just simply use RACObserve |
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 | |
public class JSON { | |
private let _value:AnyObject | |
public init(_ obj:AnyObject) { self._value = obj } | |
public init(_ json:JSON){ self._value = json._value } | |
} |
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 | |
public class JSONObject { | |
public struct Error { | |
public enum Element: Equatable { | |
case Index(Int) | |
case Key(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
// Created by Ullrich Schäfer on 16/08/14. | |
// Updated by Masashi Ono (akisute) on 26/12/14. | |
// | |
// Tested on CocoaLumberjack 2.0.0 rc | |
// | |
// CocoaLumberjack now officially supports Swift (https://github.com/CocoaLumberjack/CocoaLumberjack/blob/2.0.0-rc/Classes/CocoaLumberjack.swift), | |
// but both the current CocoaPods (0.35) with 2.2.0 rc doesn't support Swift yet. | |
// We got to workaround this by installing CocoaLumberjack.swift manually. | |
// I recommend you to use the official CocoaLumberjack.swift instead of this hack. |
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)removeViewController:(BOOL)animated | |
{ | |
CGRect destInitialFrame = self.destinationFrame; | |
CGRect destFinalFrame = CGRectMake(CGRectGetMaxX(destInitialFrame), | |
CGRectGetMinY(destInitialFrame), | |
CGRectGetWidth(destInitialFrame), | |
CGRectGetHeight(destInitialFrame)); | |
UIViewController *srcViewController = self.sourceViewController; | |
UIViewController *destViewController = self.destinationViewController; |
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)addViewController:(BOOL)animated | |
{ | |
CGRect destFinalFrame = self.destinationFrame; | |
CGRect destInitialFrame = CGRectMake(CGRectGetMaxX(destFinalFrame), | |
CGRectGetMinY(destFinalFrame), | |
CGRectGetWidth(destFinalFrame), | |
CGRectGetHeight(destFinalFrame)); | |
UIViewController *srcViewController = self.sourceViewController; | |
UIViewController *destViewController = self.destinationViewController; |