Permalink
Browse files

Include base class/protocols for mixin contraints

  • Loading branch information...
1 parent d5d0491 commit 64b5fb944ccbbb5206d11ea2554f61b91244a47d @cneuwirt committed Mar 2, 2014
@@ -6,15 +6,15 @@
// Copyright (c) 2013 Craig Neuwirt. All rights reserved.
//
-#import <Foundation/Foundation.h>
+#import "MKContextual.h"
/**
This class is an opaque mix-in that ends the current context when
the application becomes inactive. Requires the target to be Contextual.
e.g. MKEndContextWhenAppResignsMixin mixInto:MyModel.class]
*/
-@interface MKEndContextWhenAppResignsMixin : NSObject
+@interface MKEndContextWhenAppResignsMixin : NSObject <MKContextual>
+ (void)mixInto:(Class)class;
@@ -8,10 +8,9 @@
#import <UIKit/UIKit.h>
#import "MKEndContextWhenAppResignsMixin.h"
-#import "MKContextual.h"
#import "MKMixin.h"
-@interface MKEndContextWhenAppResignsMixin() <MKContextual, UIApplicationDelegate>
+@interface MKEndContextWhenAppResignsMixin() <UIApplicationDelegate>
@end
@implementation MKEndContextWhenAppResignsMixin
@@ -6,14 +6,14 @@
// Copyright (c) 2013 Craig Neuwirt. All rights reserved.
//
-#import <Foundation/Foundation.h>
+#import "MKPromise.h"
@protocol MKMasterDetail <NSObject>
@optional
-- (id<Promise>)selectedDetail:(Class)detailClass;
+- (id<MKPromise>)selectedDetail:(Class)detailClass;
-- (id<Promise>)selectedDetails:(Class)detailClass;
+- (id<MKPromise>)selectedDetails:(Class)detailClass;
- (void)selectDetail:(id)selectedDetail;
@@ -23,13 +23,13 @@
- (BOOL)hasNextDetail:(Class)detailClass;
-- (id<Promise>)previousDetail:(Class)detailClass;
+- (id<MKPromise>)previousDetail:(Class)detailClass;
-- (id<Promise>)nextDetail:(Class)detailClass;
+- (id<MKPromise>)nextDetail:(Class)detailClass;
-- (id<Promise>)addDetail:(id)detail;
+- (id<MKPromise>)addDetail:(id)detail;
-- (id<Promise>)removeDetail:(id)detail delete:(BOOL)delete;
+- (id<MKPromise>)removeDetail:(id)detail delete:(BOOL)delete;
@end
@@ -25,7 +25,7 @@
e.g. MKUserIneractionMixin mixInto:MyApplication.class]
*/
-@interface MKUserInteractionMixin : NSObject
+@interface MKUserInteractionMixin : UIApplication
+ (void)mixInto:(Class)class;
@@ -25,9 +25,8 @@ + (void)mixInto:(Class)class
- (void)swizzleUserInteraction_sendEvent:(UIEvent *)event
{
- UIApplication *application = (UIApplication *)self;
- if ([application.delegate respondsToSelector:@selector(eventDetected:)] == NO ||
- [(id)application.delegate eventDetected:event])
+ if ([self.delegate respondsToSelector:@selector(eventDetected:)] == NO ||
+ [(id)self.delegate eventDetected:event])
{
[self swizzleUserInteraction_sendEvent:event];
}
@@ -6,13 +6,13 @@
// Copyright (c) 2013 Craig Neuwirt. All rights reserved.
//
-#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
/**
This class is a mix-in that deferrs rotation decisions to the top controller.
[UINavigationController mixinFrom:UINavigationController_RotationMixin.class];
*/
-@interface UINavigationController_RotationMixin : NSObject
+@interface UINavigationController_RotationMixin : UINavigationController
@end
@@ -20,7 +20,9 @@ @implementation UINavigationController_RotationMixin
- (UIViewController *)_firstViewController
{
- return ((UINavigationController *)self).viewControllers[0];
+ return self.viewControllers.count > 0
+ ? self.viewControllers[0]
+ : nil;
}
- (BOOL)shouldAutorotate
@@ -45,7 +45,7 @@ - (MKContext *)endContextOnError
{
__block MKEndContextOnError *end = [[MKEndContextOnError allocInContext:self] init];
[end.context subscribeDidEnd:^(id<MKContext> context) {
- end = nil; // keeps refresh alive until context ends
+ end = nil; // keeps alive until context ends
}];
return end.context;
}

0 comments on commit 64b5fb9

Please sign in to comment.