Skip to content

Instantly share code, notes, and snippets.

View mikeabdullah's full-sized avatar

Mike Abdullah mikeabdullah

View GitHub Profile
@mikeabdullah
mikeabdullah / NSResponder.h
Created August 18, 2015 15:46
NSResponder: Supplement targets
@interface NSResponder
- (id)supplementalTargetForAction:(SEL)action sender:(id)sender NS_AVAILABLE_MAC(10_7);
@end
@mikeabdullah
mikeabdullah / actiondispatch.m
Created August 18, 2015 15:37
Example of custom action dispatch on iOS
id target = [self targetForAction:@selector(myAction:) sender:self];
[target myAction:self];
@mikeabdullah
mikeabdullah / UIResponder.h
Last active August 29, 2015 14:27
Some of UIResponder
@interface UIResponder
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender;
- (id)targetForAction:(SEL)action withSender:(id)sender NS_AVAILABLE_IOS(7_0);
@end
@interface UIApplication
- (BOOL)sendAction:(SEL)action to:(id)target from:(id)sender forEvent:(UIEvent *)event;
@end
@mikeabdullah
mikeabdullah / NSResponder.h
Last active August 29, 2015 14:27
Some of NSResponder
@interface NSResponder
- (BOOL)tryToPerform:(SEL)anAction with:(id)anObject;
- (void)doCommandBySelector:(SEL)aSelector;
@end
@interface NSApplication
- (BOOL)sendAction:(SEL)theAction to:(id)theTarget from:(id)sender;
- (id)targetForAction:(SEL)theAction to:(id)theTarget from:(id)sender;
@end
@mikeabdullah
mikeabdullah / gist:d767d593bfbdf74913d3
Created July 9, 2015 09:23
Disabling Vibrancy for an NSPopover
- (void)disableVibrancyForPopover:(NSPopover *)popover {
NSAppearance *appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
popover.appearance = appearance;
}
@mikeabdullah
mikeabdullah / gist:af8be11f4aa1ac7b6234
Last active August 29, 2015 14:24
Parsing a .webloc file
- (NSURL *)URLFromWeblocFileData:(NSData *)data {
NSDictionary *dict = [NSPropertyListSerialization propertyListWithData:data
options:NSPropertyListImmutable
format:NULL
error:NULL];
NSString *urlString = dict[@"URL"];
return [NSURL URLWithString:urlString];
}
@mikeabdullah
mikeabdullah / gist:2a7e49d54b95826ddda9
Created July 2, 2015 16:57
Locating child View Controllers based on containing view
- (void)viewDidLoad {
[super viewDidLoad];
for (NSViewController *aController in self.childViewControllers) {
if ([aController.view isDescendantOf:self.containerView]) {
self.contentViewController = aController;
}
}
}
@mikeabdullah
mikeabdullah / gist:f67640ffadb65cb13766
Created July 2, 2015 16:50
Locating child View Controllers based on restoration identifier
- (void)viewDidLoad {
[super viewDidLoad];
for (NSViewController *aController in self.childViewControllers) {
NSString *identifier = [aController identifier];
if ([identifier isEqualToString:@"master"]) {
self.masterViewController = aController;
}
else if ([identifier isEqualToString:@"detail"]) {
self.detailViewController = aController;
@mikeabdullah
mikeabdullah / gist:885231145a28dacbf964
Created June 2, 2015 14:45
Referencing a contained view controller on iOS
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"contained"]) {
self.contentViewController = segue.destinationViewController;
}
}
@mikeabdullah
mikeabdullah / gist:365a450389bf88ade24c
Created June 2, 2015 14:11
Referencing view controllers from a storyboard
- (void)windowDidLoad {
NSSplitViewController *splitViewController = (NSSplitViewController *)self.rootViewController;
self.masterViewController = (MyMasterViewController *)splitViewController.childViewControllers[0];
self.detailViewController = (MyDetailViewController *)splitViewController.detailViewControllers[1];
}