Created
March 15, 2017 20:56
-
-
Save soxjke/4051515865d098ec686b5afd2731554c to your computer and use it in GitHub Desktop.
NSObject+Cast
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
@interface NSObject (Cast) | |
+ (instancetype)cast:(id)object; | |
@end |
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 "NSObject+Cast.h" | |
@implementation NSObject (Cast) | |
+ (instancetype)cast:(id)object { | |
return [object isKindOfClass:self] ? object : nil; | |
} | |
@end |
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)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
if ([segueId isEqualToString:@"seagueAppointmentListToMap"]) { | |
HLJAppointment *appointment = [HLJAppointment cast:sender]; | |
HLJAppointmentMapController *controller = [HLJAppointmentMapController cast:destinationController]; | |
// property injection | |
controller.model = appointment; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment