Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b0b64c1ba9 | |||
| bc5dfa02ec | |||
| c69f5c220a | |||
| 7f28d430d0 | |||
| 30dc024903 | |||
| 6403053989 | |||
| ba352c15e8 | |||
| e9e084e6f1 | |||
| 26e92c2bd6 | |||
| 41d761f822 | |||
| 832a03bf27 | |||
| ebf5254629 | |||
| e199b529c8 | |||
| 06edea64ae | |||
| 6d3afe36d1 | |||
| b22d2b57a2 | |||
| b453086936 | |||
| 103489c566 | |||
| 3dd27557ea | |||
| a64188dd5e | |||
| 44e428655a |
@@ -17,6 +17,17 @@
|
||||
- (BOOL)shouldReceiveTouchAtWindowPoint:(CGPoint)pointInWindowCoordinates;
|
||||
- (BOOL)wantsWindowToBecomeKey;
|
||||
|
||||
// Keyboard shortcut helpers
|
||||
|
||||
- (void)toggleSelectTool;
|
||||
- (void)toggleMoveTool;
|
||||
- (void)toggleViewsTool;
|
||||
- (void)toggleMenuTool;
|
||||
- (void)handleDownArrowKeyPressed;
|
||||
- (void)handleUpArrowKeyPressed;
|
||||
- (void)handleRightArrowKeyPressed;
|
||||
- (void)handleLeftArrowKeyPressed;
|
||||
|
||||
@end
|
||||
|
||||
@protocol FLEXExplorerViewControllerDelegate <NSObject>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#import "FLEXGlobalsTableViewController.h"
|
||||
#import "FLEXObjectExplorerViewController.h"
|
||||
#import "FLEXObjectExplorerFactory.h"
|
||||
#import "FLEXNetworkHistoryTableViewController.h"
|
||||
|
||||
typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
|
||||
FLEXExplorerModeDefault,
|
||||
@@ -367,21 +368,12 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
|
||||
|
||||
- (void)selectButtonTapped:(FLEXToolbarItem *)sender
|
||||
{
|
||||
if (self.currentMode == FLEXExplorerModeSelect) {
|
||||
self.currentMode = FLEXExplorerModeDefault;
|
||||
} else {
|
||||
self.currentMode = FLEXExplorerModeSelect;
|
||||
}
|
||||
[self toggleSelectTool];
|
||||
}
|
||||
|
||||
- (void)hierarchyButtonTapped:(FLEXToolbarItem *)sender
|
||||
{
|
||||
NSArray *allViews = [self allViewsInHierarchy];
|
||||
NSDictionary *depthsForViews = [self hierarchyDepthsForViews:allViews];
|
||||
FLEXHierarchyTableViewController *hierarchyTVC = [[FLEXHierarchyTableViewController alloc] initWithViews:allViews viewsAtTap:self.viewsAtTapPoint selectedView:self.selectedView depths:depthsForViews];
|
||||
hierarchyTVC.delegate = self;
|
||||
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:hierarchyTVC];
|
||||
[self makeKeyAndPresentViewController:navigationController animated:YES completion:nil];
|
||||
[self toggleViewsTool];
|
||||
}
|
||||
|
||||
- (NSArray *)allViewsInHierarchy
|
||||
@@ -427,20 +419,12 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
|
||||
|
||||
- (void)moveButtonTapped:(FLEXToolbarItem *)sender
|
||||
{
|
||||
if (self.currentMode == FLEXExplorerModeMove) {
|
||||
self.currentMode = FLEXExplorerModeDefault;
|
||||
} else {
|
||||
self.currentMode = FLEXExplorerModeMove;
|
||||
}
|
||||
[self toggleMoveTool];
|
||||
}
|
||||
|
||||
- (void)globalsButtonTapped:(FLEXToolbarItem *)sender
|
||||
{
|
||||
FLEXGlobalsTableViewController *globalsViewController = [[FLEXGlobalsTableViewController alloc] init];
|
||||
globalsViewController.delegate = self;
|
||||
[FLEXGlobalsTableViewController setApplicationWindow:[[UIApplication sharedApplication] keyWindow]];
|
||||
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:globalsViewController];
|
||||
[self makeKeyAndPresentViewController:navigationController animated:YES completion:nil];
|
||||
[self toggleMenuTool];
|
||||
}
|
||||
|
||||
- (void)closeButtonTapped:(FLEXToolbarItem *)sender
|
||||
@@ -830,4 +814,103 @@ typedef NS_ENUM(NSUInteger, FLEXExplorerMode) {
|
||||
return self.previousKeyWindow != nil;
|
||||
}
|
||||
|
||||
#pragma mark - Keyboard Shortcut Helpers
|
||||
|
||||
- (void)toggleSelectTool
|
||||
{
|
||||
if (self.currentMode == FLEXExplorerModeSelect) {
|
||||
self.currentMode = FLEXExplorerModeDefault;
|
||||
} else {
|
||||
self.currentMode = FLEXExplorerModeSelect;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)toggleMoveTool
|
||||
{
|
||||
if (self.currentMode == FLEXExplorerModeMove) {
|
||||
self.currentMode = FLEXExplorerModeDefault;
|
||||
} else {
|
||||
self.currentMode = FLEXExplorerModeMove;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)toggleViewsTool
|
||||
{
|
||||
BOOL viewsModalShown = [[self presentedViewController] isKindOfClass:[UINavigationController class]];
|
||||
viewsModalShown = viewsModalShown && [[[(UINavigationController *)[self presentedViewController] viewControllers] firstObject] isKindOfClass:[FLEXHierarchyTableViewController class]];
|
||||
if (viewsModalShown) {
|
||||
[self resignKeyAndDismissViewControllerAnimated:YES completion:nil];
|
||||
} else {
|
||||
[self resignKeyAndDismissViewControllerAnimated:NO completion:nil];
|
||||
NSArray *allViews = [self allViewsInHierarchy];
|
||||
NSDictionary *depthsForViews = [self hierarchyDepthsForViews:allViews];
|
||||
FLEXHierarchyTableViewController *hierarchyTVC = [[FLEXHierarchyTableViewController alloc] initWithViews:allViews viewsAtTap:self.viewsAtTapPoint selectedView:self.selectedView depths:depthsForViews];
|
||||
hierarchyTVC.delegate = self;
|
||||
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:hierarchyTVC];
|
||||
[self makeKeyAndPresentViewController:navigationController animated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)toggleMenuTool
|
||||
{
|
||||
BOOL menuModalShown = [[self presentedViewController] isKindOfClass:[UINavigationController class]];
|
||||
menuModalShown = menuModalShown && [[[(UINavigationController *)[self presentedViewController] viewControllers] firstObject] isKindOfClass:[FLEXGlobalsTableViewController class]];
|
||||
if (menuModalShown) {
|
||||
[self resignKeyAndDismissViewControllerAnimated:YES completion:nil];
|
||||
} else {
|
||||
[self resignKeyAndDismissViewControllerAnimated:NO completion:nil];
|
||||
FLEXGlobalsTableViewController *globalsViewController = [[FLEXGlobalsTableViewController alloc] init];
|
||||
globalsViewController.delegate = self;
|
||||
[FLEXGlobalsTableViewController setApplicationWindow:[[UIApplication sharedApplication] keyWindow]];
|
||||
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:globalsViewController];
|
||||
[self makeKeyAndPresentViewController:navigationController animated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleDownArrowKeyPressed
|
||||
{
|
||||
if (self.currentMode == FLEXExplorerModeMove) {
|
||||
CGRect frame = self.selectedView.frame;
|
||||
frame.origin.y += 1.0 / [[UIScreen mainScreen] scale];
|
||||
self.selectedView.frame = frame;
|
||||
} else if (self.currentMode == FLEXExplorerModeSelect && [self.viewsAtTapPoint count] > 0) {
|
||||
NSInteger selectedViewIndex = [self.viewsAtTapPoint indexOfObject:self.selectedView];
|
||||
if (selectedViewIndex > 0) {
|
||||
self.selectedView = [self.viewsAtTapPoint objectAtIndex:selectedViewIndex - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleUpArrowKeyPressed
|
||||
{
|
||||
if (self.currentMode == FLEXExplorerModeMove) {
|
||||
CGRect frame = self.selectedView.frame;
|
||||
frame.origin.y -= 1.0 / [[UIScreen mainScreen] scale];
|
||||
self.selectedView.frame = frame;
|
||||
} else if (self.currentMode == FLEXExplorerModeSelect && [self.viewsAtTapPoint count] > 0) {
|
||||
NSInteger selectedViewIndex = [self.viewsAtTapPoint indexOfObject:self.selectedView];
|
||||
if (selectedViewIndex < [self.viewsAtTapPoint count] - 1) {
|
||||
self.selectedView = [self.viewsAtTapPoint objectAtIndex:selectedViewIndex + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleRightArrowKeyPressed
|
||||
{
|
||||
if (self.currentMode == FLEXExplorerModeMove) {
|
||||
CGRect frame = self.selectedView.frame;
|
||||
frame.origin.x += 1.0 / [[UIScreen mainScreen] scale];
|
||||
self.selectedView.frame = frame;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleLeftArrowKeyPressed
|
||||
{
|
||||
if (self.currentMode == FLEXExplorerModeMove) {
|
||||
CGRect frame = self.selectedView.frame;
|
||||
frame.origin.x -= 1.0 / [[UIScreen mainScreen] scale];
|
||||
self.selectedView.frame = frame;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -17,16 +17,36 @@
|
||||
|
||||
- (void)showExplorer;
|
||||
- (void)hideExplorer;
|
||||
- (void)toggleExplorer;
|
||||
|
||||
#pragma mark - Network Debugging
|
||||
|
||||
/// If this property is set to YES, FLEX will swizzle NSURLConnection*Delegate and NSURLSession*Delegate methods
|
||||
/// on classes that conform to the protocols. This allows you to view network activity history from the main FLEX menu.
|
||||
/// Full responses are kept temporarily in a size limited cache and may be pruged under memory pressure.
|
||||
@property (nonatomic, assign, getter=isNetworkDebuggingEnabled) BOOL networkDebuggingEnabled;
|
||||
|
||||
/// Defaults to 50 MB if never set. Values set here are presisted across launches of the app.
|
||||
/// Defaults to 25 MB if never set. Values set here are presisted across launches of the app.
|
||||
/// The response cache uses an NSCache, so it may purge prior to hitting the limit when the app is under memory pressure.
|
||||
@property (nonatomic, assign) NSUInteger networkResponseCacheByteLimit;
|
||||
|
||||
#pragma mark - Keyboard Shortcuts
|
||||
|
||||
/// Simulator keyboard shortcuts are enabled by default.
|
||||
/// The shortcuts will not fire when there is an active text field, text view, or other responder accepting key input.
|
||||
/// You can disable keyboard shortcuts if you have existing keyboard shortcuts that conflict with FLEX, or if you like doing things the hard way ;)
|
||||
/// Keyboard shortcuts are always disabled (and support is compiled out) in non-simulator builds
|
||||
@property (nonatomic, assign) BOOL simulatorShortcutsEnabled;
|
||||
|
||||
/// Adds an action to run when the specified key & modifier combination is pressed
|
||||
/// @param key A single character string matching a key on the keyboard
|
||||
/// @param modifiers Modifier keys such as shift, command, or alt/option
|
||||
/// @param action The block to run on the main thread when the key & modifier combination is recognized.
|
||||
/// @param description Shown the the keyboard shortcut help menu, which is accessed via the '?' key.
|
||||
/// @note The action block will be retained for the duration of the application. You may want to use weak references.
|
||||
/// @note FLEX registers several default keyboard shortcuts. Use the '?' key to see a list of shortcuts.
|
||||
- (void)registerSimulatorShortcutWithKey:(NSString *)key modifiers:(UIKeyModifierFlags)modifiers action:(dispatch_block_t)action description:(NSString *)description;
|
||||
|
||||
#pragma mark - Extensions
|
||||
|
||||
/// Adds an entry at the bottom of the list of Global State items. Call this method before this view controller is displayed.
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
#import "FLEXObjectExplorerViewController.h"
|
||||
#import "FLEXNetworkObserver.h"
|
||||
#import "FLEXNetworkRecorder.h"
|
||||
#import "FLEXKeyboardShortcutManager.h"
|
||||
#import "FLEXFileBrowserTableViewController.h"
|
||||
#import "FLEXNetworkHistoryTableViewController.h"
|
||||
#import "FLEXKeyboardHelpViewController.h"
|
||||
|
||||
@interface FLEXManager () <FLEXWindowEventDelegate, FLEXExplorerViewControllerDelegate>
|
||||
|
||||
@@ -78,6 +82,14 @@
|
||||
self.explorerWindow.hidden = YES;
|
||||
}
|
||||
|
||||
- (void)toggleExplorer {
|
||||
if (self.explorerWindow.isHidden) {
|
||||
[self showExplorer];
|
||||
} else {
|
||||
[self hideExplorer];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isHidden
|
||||
{
|
||||
return self.explorerWindow.isHidden;
|
||||
@@ -125,6 +137,110 @@
|
||||
[self hideExplorer];
|
||||
}
|
||||
|
||||
#pragma mark - Simulator Shortcuts
|
||||
|
||||
- (void)registerSimulatorShortcutWithKey:(NSString *)key modifiers:(UIKeyModifierFlags)modifiers action:(dispatch_block_t)action description:(NSString *)description
|
||||
{
|
||||
# if TARGET_OS_SIMULATOR
|
||||
[[FLEXKeyboardShortcutManager sharedManager] registerSimulatorShortcutWithKey:key modifiers:modifiers action:action description:description];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)setSimulatorShortcutsEnabled:(BOOL)simulatorShortcutsEnabled
|
||||
{
|
||||
# if TARGET_OS_SIMULATOR
|
||||
[[FLEXKeyboardShortcutManager sharedManager] setEnabled:simulatorShortcutsEnabled];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (BOOL)simulatorShortcutsEnabled
|
||||
{
|
||||
# if TARGET_OS_SIMULATOR
|
||||
return [[FLEXKeyboardShortcutManager sharedManager] isEnabled];
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)registerDefaultSimulatorShortcuts
|
||||
{
|
||||
[self registerSimulatorShortcutWithKey:@"f" modifiers:0 action:^{
|
||||
[self toggleExplorer];
|
||||
} description:@"Toggle FLEX toolbar"];
|
||||
|
||||
[self registerSimulatorShortcutWithKey:@"g" modifiers:0 action:^{
|
||||
[self showExplorerIfNeeded];
|
||||
[self.explorerViewController toggleMenuTool];
|
||||
} description:@"Toggle FLEX globlas menu"];
|
||||
|
||||
[self registerSimulatorShortcutWithKey:@"v" modifiers:0 action:^{
|
||||
[self showExplorerIfNeeded];
|
||||
[self.explorerViewController toggleViewsTool];
|
||||
} description:@"Toggle view hierarchy menu"];
|
||||
|
||||
[self registerSimulatorShortcutWithKey:@"s" modifiers:0 action:^{
|
||||
[self showExplorerIfNeeded];
|
||||
[self.explorerViewController toggleSelectTool];
|
||||
} description:@"Toggle select tool"];
|
||||
|
||||
[self registerSimulatorShortcutWithKey:@"m" modifiers:0 action:^{
|
||||
[self showExplorerIfNeeded];
|
||||
[self.explorerViewController toggleMoveTool];
|
||||
} description:@"Toggle move tool"];
|
||||
|
||||
[self registerSimulatorShortcutWithKey:@"n" modifiers:0 action:^{
|
||||
[self toggleTopViewControllerOfClass:[FLEXNetworkHistoryTableViewController class]];
|
||||
} description:@"Toggle network history view"];
|
||||
|
||||
[self registerSimulatorShortcutWithKey:UIKeyInputDownArrow modifiers:0 action:^{
|
||||
if ([self isHidden]) {
|
||||
[self tryScrollDown];
|
||||
} else {
|
||||
[self.explorerViewController handleDownArrowKeyPressed];
|
||||
}
|
||||
} description:@"Cycle view selection\n\t\tMove view down\n\t\tScroll down"];
|
||||
|
||||
[self registerSimulatorShortcutWithKey:UIKeyInputUpArrow modifiers:0 action:^{
|
||||
if ([self isHidden]) {
|
||||
[self tryScrollUp];
|
||||
} else {
|
||||
[self.explorerViewController handleUpArrowKeyPressed];
|
||||
}
|
||||
} description:@"Cycle view selection\n\t\tMove view up\n\t\tScroll up"];
|
||||
|
||||
[self registerSimulatorShortcutWithKey:UIKeyInputRightArrow modifiers:0 action:^{
|
||||
if (![self isHidden]) {
|
||||
[self.explorerViewController handleRightArrowKeyPressed];
|
||||
}
|
||||
} description:@"Move selected view right"];
|
||||
|
||||
[self registerSimulatorShortcutWithKey:UIKeyInputLeftArrow modifiers:0 action:^{
|
||||
if ([self isHidden]) {
|
||||
[self tryGoBack];
|
||||
} else {
|
||||
[self.explorerViewController handleLeftArrowKeyPressed];
|
||||
}
|
||||
} description:@"Move selected view left"];
|
||||
|
||||
[self registerSimulatorShortcutWithKey:@"?" modifiers:0 action:^{
|
||||
[self toggleTopViewControllerOfClass:[FLEXKeyboardHelpViewController class]];
|
||||
} description:@"Toggle (this) help menu"];
|
||||
|
||||
[self registerSimulatorShortcutWithKey:UIKeyInputEscape modifiers:0 action:^{
|
||||
[[[self topViewController] presentingViewController] dismissViewControllerAnimated:YES completion:nil];
|
||||
} description:@"End editing text\n\t\tDismiss top view controller"];
|
||||
|
||||
[self registerSimulatorShortcutWithKey:@"o" modifiers:UIKeyModifierCommand|UIKeyModifierShift action:^{
|
||||
[self toggleTopViewControllerOfClass:[FLEXFileBrowserTableViewController class]];
|
||||
} description:@"Toggle file browser menu"];
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[[self class] sharedManager] registerDefaultSimulatorShortcuts];
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - Extensions
|
||||
|
||||
@@ -162,4 +278,83 @@
|
||||
[self.userGlobalEntries addObject:entry];
|
||||
}
|
||||
|
||||
- (void)tryScrollDown
|
||||
{
|
||||
UIScrollView *firstScrollView = [self firstScrollView];
|
||||
CGPoint contentOffset = [firstScrollView contentOffset];
|
||||
CGFloat distance = floor(firstScrollView.frame.size.height / 2.0);
|
||||
CGFloat maxContentOffsetY = firstScrollView.contentSize.height + firstScrollView.contentInset.bottom - firstScrollView.frame.size.height;
|
||||
distance = MIN(maxContentOffsetY - firstScrollView.contentOffset.y, distance);
|
||||
contentOffset.y += distance;
|
||||
[firstScrollView setContentOffset:contentOffset animated:YES];
|
||||
}
|
||||
|
||||
- (void)tryScrollUp
|
||||
{
|
||||
UIScrollView *firstScrollView = [self firstScrollView];
|
||||
CGPoint contentOffset = [firstScrollView contentOffset];
|
||||
CGFloat distance = floor(firstScrollView.frame.size.height / 2.0);
|
||||
CGFloat minContentOffsetY = -firstScrollView.contentInset.top;
|
||||
distance = MIN(firstScrollView.contentOffset.y - minContentOffsetY, distance);
|
||||
contentOffset.y -= distance;
|
||||
[firstScrollView setContentOffset:contentOffset animated:YES];
|
||||
}
|
||||
|
||||
- (UIScrollView *)firstScrollView
|
||||
{
|
||||
NSMutableArray *views = [[[[UIApplication sharedApplication] keyWindow] subviews] mutableCopy];
|
||||
UIScrollView *scrollView = nil;
|
||||
while ([views count] > 0) {
|
||||
UIView *view = [views firstObject];
|
||||
[views removeObjectAtIndex:0];
|
||||
if ([view isKindOfClass:[UIScrollView class]]) {
|
||||
scrollView = (UIScrollView *)view;
|
||||
break;
|
||||
} else {
|
||||
[views addObjectsFromArray:[view subviews]];
|
||||
}
|
||||
}
|
||||
return scrollView;
|
||||
}
|
||||
|
||||
- (void)tryGoBack
|
||||
{
|
||||
UINavigationController *navigationController = nil;
|
||||
UIViewController *topViewController = [self topViewController];
|
||||
if ([topViewController isKindOfClass:[UINavigationController class]]) {
|
||||
navigationController = (UINavigationController *)topViewController;
|
||||
} else {
|
||||
navigationController = topViewController.navigationController;
|
||||
}
|
||||
[navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
- (UIViewController *)topViewController
|
||||
{
|
||||
UIViewController *topViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
|
||||
while ([topViewController presentedViewController]) {
|
||||
topViewController = [topViewController presentedViewController];
|
||||
}
|
||||
return topViewController;
|
||||
}
|
||||
|
||||
- (void)toggleTopViewControllerOfClass:(Class)class
|
||||
{
|
||||
UIViewController *topViewController = [self topViewController];
|
||||
if ([topViewController isKindOfClass:[UINavigationController class]] && [[[(UINavigationController *)topViewController viewControllers] firstObject] isKindOfClass:[class class]]) {
|
||||
[[topViewController presentingViewController] dismissViewControllerAnimated:YES completion:nil];
|
||||
} else {
|
||||
id viewController = [[class alloc] init];
|
||||
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
|
||||
[topViewController presentViewController:navigationController animated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showExplorerIfNeeded
|
||||
{
|
||||
if ([self isHidden]) {
|
||||
[self showExplorer];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// FLEXCookiesTableViewController.h
|
||||
// FLEX
|
||||
//
|
||||
// Created by Rich Robinson on 19/10/2015.
|
||||
// Copyright © 2015 Flipboard. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface FLEXCookiesTableViewController : UITableViewController
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// FLEXCookiesTableViewController.m
|
||||
// FLEX
|
||||
//
|
||||
// Created by Rich Robinson on 19/10/2015.
|
||||
// Copyright © 2015 Flipboard. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FLEXCookiesTableViewController.h"
|
||||
#import "FLEXObjectExplorerFactory.h"
|
||||
#import "FLEXUtility.h"
|
||||
|
||||
@interface FLEXCookiesTableViewController ()
|
||||
|
||||
@property (nonatomic, strong) NSArray *cookies;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FLEXCookiesTableViewController
|
||||
|
||||
- (id)initWithStyle:(UITableViewStyle)style {
|
||||
self = [super initWithStyle:style];
|
||||
|
||||
if (self) {
|
||||
self.title = @"Cookies";
|
||||
|
||||
NSSortDescriptor *nameSortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES selector:@selector(caseInsensitiveCompare:)];
|
||||
_cookies =[[NSHTTPCookieStorage sharedHTTPCookieStorage].cookies sortedArrayUsingDescriptors:@[nameSortDescriptor]];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSHTTPCookie *)cookieForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
return self.cookies[indexPath.row];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.cookies.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
static NSString *CellIdentifier = @"Cell";
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
|
||||
if (!cell) {
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
|
||||
cell.textLabel.font = [FLEXUtility defaultTableViewCellLabelFont];
|
||||
cell.detailTextLabel.font = [FLEXUtility defaultTableViewCellLabelFont];
|
||||
cell.detailTextLabel.textColor = [UIColor grayColor];
|
||||
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
||||
}
|
||||
|
||||
NSHTTPCookie *cookie = [self cookieForRowAtIndexPath:indexPath];
|
||||
cell.textLabel.text = [NSString stringWithFormat:@"%@ (%@)", cookie.name, cookie.value];
|
||||
cell.detailTextLabel.text = cookie.domain;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
NSHTTPCookie *cookie = [self cookieForRowAtIndexPath:indexPath];
|
||||
UIViewController *cookieViewController = (UIViewController *)[FLEXObjectExplorerFactory explorerViewControllerForObject:cookie];
|
||||
|
||||
[self.navigationController pushViewController:cookieViewController animated:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -14,6 +14,7 @@
|
||||
#import "FLEXObjectExplorerFactory.h"
|
||||
#import "FLEXLiveObjectsTableViewController.h"
|
||||
#import "FLEXFileBrowserTableViewController.h"
|
||||
#import "FLEXCookiesTableViewController.h"
|
||||
#import "FLEXGlobalsTableViewControllerEntry.h"
|
||||
#import "FLEXManager+Private.h"
|
||||
#import "FLEXSystemLogTableViewController.h"
|
||||
@@ -26,6 +27,7 @@ typedef NS_ENUM(NSUInteger, FLEXGlobalsRow) {
|
||||
FLEXGlobalsRowSystemLog,
|
||||
FLEXGlobalsRowLiveObjects,
|
||||
FLEXGlobalsRowFileBrowser,
|
||||
FLEXGlobalsCookies,
|
||||
FLEXGlobalsRowSystemLibraries,
|
||||
FLEXGlobalsRowAppClasses,
|
||||
FLEXGlobalsRowAppDelegate,
|
||||
@@ -162,6 +164,15 @@ typedef NS_ENUM(NSUInteger, FLEXGlobalsRow) {
|
||||
};
|
||||
break;
|
||||
|
||||
case FLEXGlobalsCookies:
|
||||
titleFuture = ^NSString *{
|
||||
return @"🍪 Cookies";
|
||||
};
|
||||
viewControllerFuture = ^UIViewController *{
|
||||
return [[FLEXCookiesTableViewController alloc] init];
|
||||
};
|
||||
break;
|
||||
|
||||
case FLEXGlobalsRowFileBrowser:
|
||||
titleFuture = ^NSString *{
|
||||
return @"📁 File Browser";
|
||||
|
||||
@@ -39,9 +39,6 @@
|
||||
UITableViewCell *networkDebuggingCell = [self switchCellWithTitle:@"Network Debugging" toggleAction:@selector(networkDebuggingToggled:) isOn:[FLEXNetworkObserver isEnabled]];
|
||||
[mutableCells addObject:networkDebuggingCell];
|
||||
|
||||
UITableViewCell *enableOnLaunchCell = [self switchCellWithTitle:@"Enable on Launch" toggleAction:@selector(enableOnLaunchToggled:) isOn:[FLEXNetworkObserver shouldEnableOnLaunch]];
|
||||
[mutableCells addObject:enableOnLaunchCell];
|
||||
|
||||
UITableViewCell *cacheMediaResponsesCell = [self switchCellWithTitle:@"Cache Media Responses" toggleAction:@selector(cacheMediaResponsesToggled:) isOn:NO];
|
||||
[mutableCells addObject:cacheMediaResponsesCell];
|
||||
|
||||
@@ -64,11 +61,6 @@
|
||||
[FLEXNetworkObserver setEnabled:sender.isOn];
|
||||
}
|
||||
|
||||
- (void)enableOnLaunchToggled:(UISwitch *)sender
|
||||
{
|
||||
[FLEXNetworkObserver setShouldEnableOnLaunch:sender.isOn];
|
||||
}
|
||||
|
||||
- (void)cacheMediaResponsesToggled:(UISwitch *)sender
|
||||
{
|
||||
[[FLEXNetworkRecorder defaultRecorder] setShouldCacheMediaResponses:sender.isOn];
|
||||
|
||||
@@ -127,11 +127,13 @@ NSString *const kFLEXNetworkTransactionCellIdentifier = @"kFLEXNetworkTransactio
|
||||
NSMutableArray *detailComponents = [NSMutableArray array];
|
||||
|
||||
NSString *timestamp = [[self class] timestampStringFromRequestDate:self.transaction.startTime];
|
||||
[detailComponents addObject:timestamp];
|
||||
if ([timestamp length] > 0) {
|
||||
[detailComponents addObject:timestamp];
|
||||
}
|
||||
|
||||
// Omit method for GET (assumed as default)
|
||||
NSString *httpMethod = self.transaction.request.HTTPMethod;
|
||||
if (httpMethod) {
|
||||
if ([httpMethod length] > 0) {
|
||||
[detailComponents addObject:httpMethod];
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,8 @@ extern NSString *const kFLEXNetworkObserverEnabledStateChangedNotification;
|
||||
|
||||
/// Swizzling occurs when the observer is enabled for the first time.
|
||||
/// This reduces the impact of FLEX if network debugging is not desired.
|
||||
/// NOTE: this setting persists between launches of the app.
|
||||
+ (void)setEnabled:(BOOL)enabled;
|
||||
+ (BOOL)isEnabled;
|
||||
|
||||
/// The enable on launch setting is persisted accross launches of the app.
|
||||
/// If YES, the observer will automatically enable itself early in the application lifecycle.
|
||||
+ (void)setShouldEnableOnLaunch:(BOOL)shouldEnableOnLaunch;
|
||||
+ (BOOL)shouldEnableOnLaunch;
|
||||
|
||||
@end
|
||||
|
||||
@@ -14,13 +14,14 @@
|
||||
|
||||
#import "FLEXNetworkObserver.h"
|
||||
#import "FLEXNetworkRecorder.h"
|
||||
#import "FLEXUtility.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
#import <objc/message.h>
|
||||
#import <dispatch/queue.h>
|
||||
|
||||
NSString *const kFLEXNetworkObserverEnabledStateChangedNotification = @"kFLEXNetworkObserverEnabledStateChangedNotification";
|
||||
static NSString *const kFLEXNetworkObserverEnableOnLaunchDefaultsKey = @"com.flex.FLEXNetworkObserver.enableOnLaunch";
|
||||
static NSString *const kFLEXNetworkObserverEnabledDefaultsKey = @"com.flex.FLEXNetworkObserver.enableOnLaunch";
|
||||
|
||||
typedef void (^NSURLSessionAsyncCompletion)(id fileURLOrData, NSURLResponse *response, NSError *error);
|
||||
|
||||
@@ -67,7 +68,6 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
|
||||
@interface FLEXNetworkObserver ()
|
||||
|
||||
@property (nonatomic, assign, getter=isEnabled) BOOL enabled;
|
||||
@property (nonatomic, strong) NSMutableDictionary *requestStatesForRequestIDs;
|
||||
@property (nonatomic, strong) dispatch_queue_t queue;
|
||||
|
||||
@@ -79,43 +79,32 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
|
||||
+ (void)setEnabled:(BOOL)enabled
|
||||
{
|
||||
BOOL previouslyEnabled = [self isEnabled];
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:kFLEXNetworkObserverEnabledDefaultsKey];
|
||||
|
||||
if (enabled) {
|
||||
// Inject if needed. This injection is protected with a dispatch_once, so we're ok calling it multiple times.
|
||||
// By doing the injection lazily, we keep the impact of the tool lower when this feature isn't enabled.
|
||||
[self injectIntoAllNSURLConnectionDelegateClasses];
|
||||
}
|
||||
[[self sharedObserver] setEnabled:enabled];
|
||||
}
|
||||
|
||||
+ (BOOL)isEnabled
|
||||
{
|
||||
return [[self sharedObserver] isEnabled];
|
||||
}
|
||||
|
||||
- (void)setEnabled:(BOOL)enabled
|
||||
{
|
||||
if (_enabled != enabled) {
|
||||
_enabled = enabled;
|
||||
|
||||
if (previouslyEnabled != enabled) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kFLEXNetworkObserverEnabledStateChangedNotification object:self];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)setShouldEnableOnLaunch:(BOOL)shouldEnableOnLaunch
|
||||
+ (BOOL)isEnabled
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setBool:shouldEnableOnLaunch forKey:kFLEXNetworkObserverEnableOnLaunchDefaultsKey];
|
||||
}
|
||||
|
||||
+ (BOOL)shouldEnableOnLaunch
|
||||
{
|
||||
return [[[NSUserDefaults standardUserDefaults] objectForKey:kFLEXNetworkObserverEnableOnLaunchDefaultsKey] boolValue];
|
||||
return [[[NSUserDefaults standardUserDefaults] objectForKey:kFLEXNetworkObserverEnabledDefaultsKey] boolValue];
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
// We don't want to do the swizzling from +load because not all the classes may be loaded at this point.
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if ([self shouldEnableOnLaunch]) {
|
||||
[self setEnabled:YES];
|
||||
if ([self isEnabled]) {
|
||||
[self injectIntoAllNSURLConnectionDelegateClasses];
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -139,11 +128,6 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
|
||||
#pragma mark Delegate Injection Convenience Methods
|
||||
|
||||
+ (SEL)swizzledSelectorForSelector:(SEL)selector
|
||||
{
|
||||
return NSSelectorFromString([NSString stringWithFormat:@"_flex_swizzle_%x_%@", arc4random(), NSStringFromSelector(selector)]);
|
||||
}
|
||||
|
||||
/// All swizzled delegate methods should make use of this guard.
|
||||
/// This will prevent duplicated sniffing when the original implementation calls up to a superclass implementation which we've also swizzled.
|
||||
/// The superclass implementation (and implementations in classes above that) will be executed without inteference if called from the original implementation.
|
||||
@@ -170,66 +154,6 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
objc_setAssociatedObject(object, key, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
+ (BOOL)instanceRespondsButDoesNotImplementSelector:(SEL)selector class:(Class)cls
|
||||
{
|
||||
if ([cls instancesRespondToSelector:selector]) {
|
||||
unsigned int numMethods = 0;
|
||||
Method *methods = class_copyMethodList(cls, &numMethods);
|
||||
|
||||
BOOL implementsSelector = NO;
|
||||
for (int index = 0; index < numMethods; index++) {
|
||||
SEL methodSelector = method_getName(methods[index]);
|
||||
if (selector == methodSelector) {
|
||||
implementsSelector = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(methods);
|
||||
|
||||
if (!implementsSelector) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (void)replaceImplementationOfKnownSelector:(SEL)originalSelector onClass:(Class)class withBlock:(id)block swizzledSelector:(SEL)swizzledSelector
|
||||
{
|
||||
// This method is only intended for swizzling methods that are know to exist on the class.
|
||||
// Bail if that isn't the case.
|
||||
Method originalMethod = class_getInstanceMethod(class, originalSelector);
|
||||
if (!originalMethod) {
|
||||
return;
|
||||
}
|
||||
|
||||
IMP implementation = imp_implementationWithBlock(block);
|
||||
class_addMethod(class, swizzledSelector, implementation, method_getTypeEncoding(originalMethod));
|
||||
Method newMethod = class_getInstanceMethod(class, swizzledSelector);
|
||||
method_exchangeImplementations(originalMethod, newMethod);
|
||||
}
|
||||
|
||||
+ (void)replaceImplementationOfSelector:(SEL)selector withSelector:(SEL)swizzledSelector forClass:(Class)cls withMethodDescription:(struct objc_method_description)methodDescription implementationBlock:(id)implementationBlock undefinedBlock:(id)undefinedBlock
|
||||
{
|
||||
if ([self instanceRespondsButDoesNotImplementSelector:selector class:cls]) {
|
||||
return;
|
||||
}
|
||||
|
||||
IMP implementation = imp_implementationWithBlock((id)([cls instancesRespondToSelector:selector] ? implementationBlock : undefinedBlock));
|
||||
|
||||
Method oldMethod = class_getInstanceMethod(cls, selector);
|
||||
if (oldMethod) {
|
||||
class_addMethod(cls, swizzledSelector, implementation, methodDescription.types);
|
||||
|
||||
Method newMethod = class_getInstanceMethod(cls, swizzledSelector);
|
||||
|
||||
method_exchangeImplementations(oldMethod, newMethod);
|
||||
} else {
|
||||
class_addMethod(cls, selector, implementation, methodDescription.types);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Delegate Injection
|
||||
|
||||
+ (void)injectIntoAllNSURLConnectionDelegateClasses
|
||||
@@ -333,7 +257,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
dispatch_once(&onceToken, ^{
|
||||
Class class = [NSURLConnection class];
|
||||
SEL selector = @selector(cancel);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
Method originalCancel = class_getInstanceMethod(class, selector);
|
||||
|
||||
void (^swizzleBlock)(NSURLConnection *) = ^(NSURLConnection *slf) {
|
||||
@@ -364,7 +288,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
class = NSClassFromString([@[@"__", @"NSC", @"FURLS", @"ession", @"Task"] componentsJoinedByString:@""]);
|
||||
}
|
||||
SEL selector = @selector(resume);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
Method originalResume = class_getInstanceMethod(class, selector);
|
||||
|
||||
@@ -386,7 +310,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
dispatch_once(&onceToken, ^{
|
||||
Class class = objc_getMetaClass(class_getName([NSURLConnection class]));
|
||||
SEL selector = @selector(sendAsynchronousRequest:queue:completionHandler:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
typedef void (^NSURLConnectionAsyncCompletion)(NSURLResponse* response, NSData* data, NSError* connectionError);
|
||||
|
||||
@@ -416,7 +340,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
}
|
||||
};
|
||||
|
||||
[self replaceImplementationOfKnownSelector:selector onClass:class withBlock:asyncSwizzleBlock swizzledSelector:swizzledSelector];
|
||||
[FLEXUtility replaceImplementationOfKnownSelector:selector onClass:class withBlock:asyncSwizzleBlock swizzledSelector:swizzledSelector];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -426,7 +350,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
dispatch_once(&onceToken, ^{
|
||||
Class class = objc_getMetaClass(class_getName([NSURLConnection class]));
|
||||
SEL selector = @selector(sendSynchronousRequest:returningResponse:error:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
NSData *(^syncSwizzleBlock)(Class, NSURLRequest *, NSURLResponse **, NSError **) = ^NSData *(Class slf, NSURLRequest *request, NSURLResponse **response, NSError **error) {
|
||||
NSData *data = nil;
|
||||
@@ -458,7 +382,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
return data;
|
||||
};
|
||||
|
||||
[self replaceImplementationOfKnownSelector:selector onClass:class withBlock:syncSwizzleBlock swizzledSelector:swizzledSelector];
|
||||
[FLEXUtility replaceImplementationOfKnownSelector:selector onClass:class withBlock:syncSwizzleBlock swizzledSelector:swizzledSelector];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -481,9 +405,9 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
|
||||
for (int selectorIndex = 0; selectorIndex < numSelectors; selectorIndex++) {
|
||||
SEL selector = selectors[selectorIndex];
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
if ([self instanceRespondsButDoesNotImplementSelector:selector class:class]) {
|
||||
if ([FLEXUtility instanceRespondsButDoesNotImplementSelector:selector class:class]) {
|
||||
// iOS 7 does not implement these methods on NSURLSession. We actually want to
|
||||
// swizzle __NSCFURLSession, which we can get from the class of the shared session
|
||||
class = [[NSURLSession sharedSession] class];
|
||||
@@ -506,7 +430,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
return task;
|
||||
};
|
||||
|
||||
[self replaceImplementationOfKnownSelector:selector onClass:class withBlock:asyncDataOrDownloadSwizzleBlock swizzledSelector:swizzledSelector];
|
||||
[FLEXUtility replaceImplementationOfKnownSelector:selector onClass:class withBlock:asyncDataOrDownloadSwizzleBlock swizzledSelector:swizzledSelector];
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -528,9 +452,9 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
|
||||
for (int selectorIndex = 0; selectorIndex < numSelectors; selectorIndex++) {
|
||||
SEL selector = selectors[selectorIndex];
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
if ([self instanceRespondsButDoesNotImplementSelector:selector class:class]) {
|
||||
if ([FLEXUtility instanceRespondsButDoesNotImplementSelector:selector class:class]) {
|
||||
// iOS 7 does not implement these methods on NSURLSession. We actually want to
|
||||
// swizzle __NSCFURLSession, which we can get from the class of the shared session
|
||||
class = [[NSURLSession sharedSession] class];
|
||||
@@ -550,7 +474,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
return task;
|
||||
};
|
||||
|
||||
[self replaceImplementationOfKnownSelector:selector onClass:class withBlock:asyncUploadTaskSwizzleBlock swizzledSelector:swizzledSelector];
|
||||
[FLEXUtility replaceImplementationOfKnownSelector:selector onClass:class withBlock:asyncUploadTaskSwizzleBlock swizzledSelector:swizzledSelector];
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -589,7 +513,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
+ (void)injectWillSendRequestIntoDelegateClass:(Class)cls
|
||||
{
|
||||
SEL selector = @selector(connection:willSendRequest:redirectResponse:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
Protocol *protocol = @protocol(NSURLConnectionDataDelegate);
|
||||
if (!protocol) {
|
||||
@@ -615,13 +539,13 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
return returnValue;
|
||||
};
|
||||
|
||||
[self replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
[FLEXUtility replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
}
|
||||
|
||||
+ (void)injectDidReceiveResponseIntoDelegateClass:(Class)cls
|
||||
{
|
||||
SEL selector = @selector(connection:didReceiveResponse:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
Protocol *protocol = @protocol(NSURLConnectionDataDelegate);
|
||||
if (!protocol) {
|
||||
@@ -644,13 +568,13 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
}];
|
||||
};
|
||||
|
||||
[self replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
[FLEXUtility replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
}
|
||||
|
||||
+ (void)injectDidReceiveDataIntoDelegateClass:(Class)cls
|
||||
{
|
||||
SEL selector = @selector(connection:didReceiveData:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
Protocol *protocol = @protocol(NSURLConnectionDataDelegate);
|
||||
if (!protocol) {
|
||||
@@ -673,13 +597,13 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
}];
|
||||
};
|
||||
|
||||
[self replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
[FLEXUtility replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
}
|
||||
|
||||
+ (void)injectDidFinishLoadingIntoDelegateClass:(Class)cls
|
||||
{
|
||||
SEL selector = @selector(connectionDidFinishLoading:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
Protocol *protocol = @protocol(NSURLConnectionDataDelegate);
|
||||
if (!protocol) {
|
||||
@@ -702,13 +626,13 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
}];
|
||||
};
|
||||
|
||||
[self replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
[FLEXUtility replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
}
|
||||
|
||||
+ (void)injectDidFailWithErrorIntoDelegateClass:(Class)cls
|
||||
{
|
||||
SEL selector = @selector(connection:didFailWithError:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
Protocol *protocol = @protocol(NSURLConnectionDelegate);
|
||||
struct objc_method_description methodDescription = protocol_getMethodDescription(protocol, selector, NO, YES);
|
||||
@@ -727,13 +651,13 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
}];
|
||||
};
|
||||
|
||||
[self replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
[FLEXUtility replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
}
|
||||
|
||||
+ (void)injectTaskWillPerformHTTPRedirectionIntoDelegateClass:(Class)cls
|
||||
{
|
||||
SEL selector = @selector(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
Protocol *protocol = @protocol(NSURLSessionTaskDelegate);
|
||||
|
||||
@@ -753,14 +677,14 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
}];
|
||||
};
|
||||
|
||||
[self replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
[FLEXUtility replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
|
||||
}
|
||||
|
||||
+ (void)injectTaskDidReceiveDataIntoDelegateClass:(Class)cls
|
||||
{
|
||||
SEL selector = @selector(URLSession:dataTask:didReceiveData:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
Protocol *protocol = @protocol(NSURLSessionDataDelegate);
|
||||
|
||||
@@ -780,14 +704,14 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
}];
|
||||
};
|
||||
|
||||
[self replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
[FLEXUtility replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
|
||||
}
|
||||
|
||||
+ (void)injectDataTaskDidBecomeDownloadTaskIntoDelegateClass:(Class)cls
|
||||
{
|
||||
SEL selector = @selector(URLSession:dataTask:didBecomeDownloadTask:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
Protocol *protocol = @protocol(NSURLSessionDataDelegate);
|
||||
|
||||
@@ -807,13 +731,13 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
}];
|
||||
};
|
||||
|
||||
[self replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
[FLEXUtility replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
}
|
||||
|
||||
+ (void)injectTaskDidReceiveResponseIntoDelegateClass:(Class)cls
|
||||
{
|
||||
SEL selector = @selector(URLSession:dataTask:didReceiveResponse:completionHandler:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
Protocol *protocol = @protocol(NSURLSessionDataDelegate);
|
||||
|
||||
@@ -833,14 +757,14 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
}];
|
||||
};
|
||||
|
||||
[self replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
[FLEXUtility replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
|
||||
}
|
||||
|
||||
+ (void)injectTaskDidCompleteWithErrorIntoDelegateClass:(Class)cls
|
||||
{
|
||||
SEL selector = @selector(URLSession:task:didCompleteWithError:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
Protocol *protocol = @protocol(NSURLSessionTaskDelegate);
|
||||
struct objc_method_description methodDescription = protocol_getMethodDescription(protocol, selector, NO, YES);
|
||||
@@ -859,14 +783,14 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
}];
|
||||
};
|
||||
|
||||
[self replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
[FLEXUtility replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
}
|
||||
|
||||
// Used for overriding AFNetworking behavior
|
||||
+ (void)injectRespondsToSelectorIntoDelegateClass:(Class)cls
|
||||
{
|
||||
SEL selector = @selector(respondsToSelector:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
//Protocol *protocol = @protocol(NSURLSessionTaskDelegate);
|
||||
Method method = class_getInstanceMethod(cls, selector);
|
||||
@@ -883,14 +807,14 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
return ((BOOL(*)(id, SEL, SEL))objc_msgSend)(slf, swizzledSelector, sel);
|
||||
};
|
||||
|
||||
[self replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
[FLEXUtility replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
}
|
||||
|
||||
|
||||
+ (void)injectDownloadTaskDidFinishDownloadingIntoDelegateClass:(Class)cls
|
||||
{
|
||||
SEL selector = @selector(URLSession:downloadTask:didFinishDownloadingToURL:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
Protocol *protocol = @protocol(NSURLSessionDownloadDelegate);
|
||||
struct objc_method_description methodDescription = protocol_getMethodDescription(protocol, selector, NO, YES);
|
||||
@@ -910,13 +834,13 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
}];
|
||||
};
|
||||
|
||||
[self replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
[FLEXUtility replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
}
|
||||
|
||||
+ (void)injectDownloadTaskDidWriteDataIntoDelegateClass:(Class)cls
|
||||
{
|
||||
SEL selector = @selector(URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:);
|
||||
SEL swizzledSelector = [self swizzledSelectorForSelector:selector];
|
||||
SEL swizzledSelector = [FLEXUtility swizzledSelectorForSelector:selector];
|
||||
|
||||
Protocol *protocol = @protocol(NSURLSessionDownloadDelegate);
|
||||
struct objc_method_description methodDescription = protocol_getMethodDescription(protocol, selector, NO, YES);
|
||||
@@ -935,7 +859,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
|
||||
}];
|
||||
};
|
||||
|
||||
[self replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
[FLEXUtility replaceImplementationOfSelector:selector withSelector:swizzledSelector forClass:cls withMethodDescription:methodDescription implementationBlock:implementationBlock undefinedBlock:undefinedBlock];
|
||||
|
||||
}
|
||||
|
||||
@@ -972,7 +896,7 @@ static char const * const kFLEXRequestIDKey = "kFLEXRequestIDKey";
|
||||
|
||||
- (void)performBlock:(dispatch_block_t)block
|
||||
{
|
||||
if (self.isEnabled) {
|
||||
if ([[self class] isEnabled]) {
|
||||
dispatch_async(_queue, block);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// FLEXKeyboardHelpViewController.h
|
||||
// UICatalog
|
||||
//
|
||||
// Created by Ryan Olson on 9/19/15.
|
||||
// Copyright © 2015 f. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface FLEXKeyboardHelpViewController : UIViewController
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// FLEXKeyboardHelpViewController.m
|
||||
// UICatalog
|
||||
//
|
||||
// Created by Ryan Olson on 9/19/15.
|
||||
// Copyright © 2015 f. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FLEXKeyboardHelpViewController.h"
|
||||
#import "FLEXKeyboardShortcutManager.h"
|
||||
|
||||
@interface FLEXKeyboardHelpViewController ()
|
||||
|
||||
@property (nonatomic, strong) UITextView *textView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FLEXKeyboardHelpViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.textView = [[UITextView alloc] initWithFrame:self.view.bounds];
|
||||
self.textView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
|
||||
[self.view addSubview:self.textView];
|
||||
#if TARGET_OS_SIMULATOR
|
||||
self.textView.text = [[FLEXKeyboardShortcutManager sharedManager] keyboardShortcutsDescription];
|
||||
#endif
|
||||
self.textView.backgroundColor = [UIColor blackColor];
|
||||
self.textView.textColor = [UIColor whiteColor];
|
||||
self.textView.font = [UIFont boldSystemFontOfSize:14.0];
|
||||
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
|
||||
|
||||
self.title = @"Simulator Shortcuts";
|
||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(donePressed:)];
|
||||
}
|
||||
|
||||
- (void)donePressed:(id)sender
|
||||
{
|
||||
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// FLEXKeyboardShortcutManager.h
|
||||
// FLEX
|
||||
//
|
||||
// Created by Ryan Olson on 9/19/15.
|
||||
// Copyright © 2015 Flipboard. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#if TARGET_OS_SIMULATOR
|
||||
|
||||
@interface FLEXKeyboardShortcutManager : NSObject
|
||||
|
||||
+ (instancetype)sharedManager;
|
||||
|
||||
- (void)registerSimulatorShortcutWithKey:(NSString *)key modifiers:(UIKeyModifierFlags)modifiers action:(dispatch_block_t)action description:(NSString *)description;
|
||||
- (NSString *)keyboardShortcutsDescription;
|
||||
|
||||
@property (nonatomic, assign, getter=isEnabled) BOOL enabled;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,243 @@
|
||||
//
|
||||
// FLEXKeyboardShortcutManager.m
|
||||
// FLEX
|
||||
//
|
||||
// Created by Ryan Olson on 9/19/15.
|
||||
// Copyright © 2015 Flipboard. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FLEXKeyboardShortcutManager.h"
|
||||
#import "FLEXUtility.h"
|
||||
#import <objc/runtime.h>
|
||||
#import <objc/message.h>
|
||||
|
||||
#if TARGET_OS_SIMULATOR
|
||||
|
||||
@interface UIEvent (UIPhysicalKeyboardEvent)
|
||||
|
||||
@property (nonatomic, strong) NSString *_modifiedInput;
|
||||
@property (nonatomic, strong) NSString *_unmodifiedInput;
|
||||
@property (nonatomic, assign) UIKeyModifierFlags _modifierFlags;
|
||||
@property (nonatomic, assign) BOOL _isKeyDown;
|
||||
|
||||
@end
|
||||
|
||||
@interface FLEXKeyInput : NSObject <NSCopying>
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *key;
|
||||
@property (nonatomic, assign, readonly) UIKeyModifierFlags flags;
|
||||
@property (nonatomic, copy, readonly) NSString *helpDescription;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FLEXKeyInput
|
||||
|
||||
- (BOOL)isEqual:(id)object
|
||||
{
|
||||
BOOL isEqual = NO;
|
||||
if ([object isKindOfClass:[FLEXKeyInput class]]) {
|
||||
FLEXKeyInput *keyCommand = (FLEXKeyInput *)object;
|
||||
BOOL equalKeys = self.key == keyCommand.key || [self.key isEqual:keyCommand.key];
|
||||
BOOL equalFlags = self.flags == keyCommand.flags;
|
||||
isEqual = equalKeys && equalFlags;
|
||||
}
|
||||
return isEqual;
|
||||
}
|
||||
|
||||
- (NSUInteger)hash
|
||||
{
|
||||
return [self.key hash] ^ self.flags;
|
||||
}
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone
|
||||
{
|
||||
return [[self class] keyInputForKey:self.key flags:self.flags helpDescription:self.helpDescription];
|
||||
}
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
NSDictionary *keyMappings = @{ UIKeyInputUpArrow : @"↑",
|
||||
UIKeyInputDownArrow : @"↓",
|
||||
UIKeyInputLeftArrow : @"←",
|
||||
UIKeyInputRightArrow : @"→",
|
||||
UIKeyInputEscape : @"␛",
|
||||
@" " : @"␠"};
|
||||
|
||||
NSString *prettyKey = nil;
|
||||
if (self.key && [keyMappings objectForKey:self.key]) {
|
||||
prettyKey = [keyMappings objectForKey:self.key];
|
||||
} else {
|
||||
prettyKey = [self.key uppercaseString];
|
||||
}
|
||||
|
||||
NSString *prettyFlags = @"";
|
||||
if (self.flags & UIKeyModifierControl) {
|
||||
prettyFlags = [prettyFlags stringByAppendingString:@"⌃"];
|
||||
}
|
||||
if (self.flags & UIKeyModifierAlternate) {
|
||||
prettyFlags = [prettyFlags stringByAppendingString:@"⌥"];
|
||||
}
|
||||
if (self.flags & UIKeyModifierShift) {
|
||||
prettyFlags = [prettyFlags stringByAppendingString:@"⇧"];
|
||||
}
|
||||
if (self.flags & UIKeyModifierCommand) {
|
||||
prettyFlags = [prettyFlags stringByAppendingString:@"⌘"];
|
||||
}
|
||||
|
||||
// Fudging to get easy columns with tabs
|
||||
if ([prettyFlags length] < 2) {
|
||||
prettyKey = [prettyKey stringByAppendingString:@"\t"];
|
||||
}
|
||||
|
||||
return [NSString stringWithFormat:@"%@%@\t%@", prettyFlags, prettyKey, self.helpDescription];
|
||||
}
|
||||
|
||||
+ (instancetype)keyInputForKey:(NSString *)key flags:(UIKeyModifierFlags)flags
|
||||
{
|
||||
return [self keyInputForKey:key flags:flags helpDescription:nil];
|
||||
}
|
||||
|
||||
+ (instancetype)keyInputForKey:(NSString *)key flags:(UIKeyModifierFlags)flags helpDescription:(NSString *)helpDescription
|
||||
{
|
||||
FLEXKeyInput *keyInput = [[self alloc] init];
|
||||
if (keyInput) {
|
||||
keyInput->_key = key;
|
||||
keyInput->_flags = flags;
|
||||
keyInput->_helpDescription = helpDescription;
|
||||
}
|
||||
return keyInput;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface FLEXKeyboardShortcutManager ()
|
||||
|
||||
@property (nonatomic, strong) NSMutableDictionary *actionsForKeyInputs;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FLEXKeyboardShortcutManager
|
||||
|
||||
+ (instancetype)sharedManager
|
||||
{
|
||||
static FLEXKeyboardShortcutManager *sharedManager = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedManager = [[[self class] alloc] init];
|
||||
});
|
||||
return sharedManager;
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
SEL originalKeyEventSelector = NSSelectorFromString(@"handleKeyUIEvent:");
|
||||
SEL swizzledKeyEventSelector = [FLEXUtility swizzledSelectorForSelector:originalKeyEventSelector];
|
||||
|
||||
void (^sendEventSwizzleBlock)(UIApplication *, UIEvent *) = ^(UIApplication *slf, UIEvent *event) {
|
||||
|
||||
[[[self class] sharedManager] handleKeyboardEvent:event];
|
||||
|
||||
((void(*)(id, SEL, id))objc_msgSend)(slf, swizzledKeyEventSelector, event);
|
||||
};
|
||||
|
||||
[FLEXUtility replaceImplementationOfKnownSelector:originalKeyEventSelector onClass:[UIApplication class] withBlock:sendEventSwizzleBlock swizzledSelector:swizzledKeyEventSelector];
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
_actionsForKeyInputs = [NSMutableDictionary dictionary];
|
||||
_enabled = YES;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)registerSimulatorShortcutWithKey:(NSString *)key modifiers:(UIKeyModifierFlags)modifiers action:(dispatch_block_t)action description:(NSString *)description
|
||||
{
|
||||
FLEXKeyInput *keyInput = [FLEXKeyInput keyInputForKey:key flags:modifiers helpDescription:description];
|
||||
[self.actionsForKeyInputs setObject:action forKey:keyInput];
|
||||
}
|
||||
|
||||
- (void)handleKeyboardEvent:(UIEvent *)event
|
||||
{
|
||||
if (!self.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *modifiedInput = nil;
|
||||
NSString *unmodifiedInput = nil;
|
||||
UIKeyModifierFlags flags = 0;
|
||||
BOOL isKeyDown = NO;
|
||||
|
||||
if ([event respondsToSelector:@selector(_modifiedInput)]) {
|
||||
modifiedInput = [event _modifiedInput];
|
||||
}
|
||||
|
||||
if ([event respondsToSelector:@selector(_unmodifiedInput)]) {
|
||||
unmodifiedInput = [event _unmodifiedInput];
|
||||
}
|
||||
|
||||
if ([event respondsToSelector:@selector(_modifierFlags)]) {
|
||||
flags = [event _modifierFlags];
|
||||
}
|
||||
|
||||
if ([event respondsToSelector:@selector(_isKeyDown)]) {
|
||||
isKeyDown = [event _isKeyDown];
|
||||
}
|
||||
|
||||
BOOL interactionEnabled = ![[UIApplication sharedApplication] isIgnoringInteractionEvents];
|
||||
|
||||
if (isKeyDown && [modifiedInput length] > 0 && interactionEnabled) {
|
||||
UIResponder *firstResponder = nil;
|
||||
for (UIWindow *window in [[UIApplication sharedApplication] windows]) {
|
||||
firstResponder = [window valueForKey:@"firstResponder"];
|
||||
if (firstResponder) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Ignore key commands (except escape) when there's an active responder
|
||||
if (firstResponder) {
|
||||
if ([unmodifiedInput isEqual:UIKeyInputEscape]) {
|
||||
[firstResponder resignFirstResponder];
|
||||
}
|
||||
} else {
|
||||
FLEXKeyInput *exactMatch = [FLEXKeyInput keyInputForKey:unmodifiedInput flags:flags];
|
||||
|
||||
dispatch_block_t actionBlock = [self.actionsForKeyInputs objectForKey:exactMatch];
|
||||
|
||||
if (!actionBlock) {
|
||||
FLEXKeyInput *shiftMatch = [FLEXKeyInput keyInputForKey:modifiedInput flags:flags&(!UIKeyModifierShift)];
|
||||
actionBlock = [self.actionsForKeyInputs objectForKey:shiftMatch];
|
||||
}
|
||||
|
||||
if (!actionBlock) {
|
||||
FLEXKeyInput *capitalMatch = [FLEXKeyInput keyInputForKey:[unmodifiedInput uppercaseString] flags:flags];
|
||||
actionBlock = [self.actionsForKeyInputs objectForKey:capitalMatch];
|
||||
}
|
||||
|
||||
if (actionBlock) {
|
||||
actionBlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)keyboardShortcutsDescription
|
||||
{
|
||||
NSMutableString *description = [NSMutableString string];
|
||||
NSArray *keyInputs = [[self.actionsForKeyInputs allKeys] sortedArrayUsingComparator:^NSComparisonResult(FLEXKeyInput *_Nonnull input1, FLEXKeyInput *_Nonnull input2) {
|
||||
return [input1.key caseInsensitiveCompare:input2.key];
|
||||
}];
|
||||
for (FLEXKeyInput *keyInput in keyInputs) {
|
||||
[description appendFormat:@"%@\n", keyInput];
|
||||
}
|
||||
return [description copy];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#define FLEXFloor(x) (floor([[UIScreen mainScreen] scale] * (x)) / [[UIScreen mainScreen] scale])
|
||||
|
||||
@@ -38,4 +39,11 @@
|
||||
+ (BOOL)isValidJSONData:(NSData *)data;
|
||||
+ (NSData *)inflatedDataFromCompressedData:(NSData *)compressedData;
|
||||
|
||||
// Swizzling utilities
|
||||
|
||||
+ (SEL)swizzledSelectorForSelector:(SEL)selector;
|
||||
+ (BOOL)instanceRespondsButDoesNotImplementSelector:(SEL)selector class:(Class)cls;
|
||||
+ (void)replaceImplementationOfKnownSelector:(SEL)originalSelector onClass:(Class)class withBlock:(id)block swizzledSelector:(SEL)swizzledSelector;
|
||||
+ (void)replaceImplementationOfSelector:(SEL)selector withSelector:(SEL)swizzledSelector forClass:(Class)cls withMethodDescription:(struct objc_method_description)methodDescription implementationBlock:(id)implementationBlock undefinedBlock:(id)undefinedBlock;
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#import "FLEXResources.h"
|
||||
#import <ImageIO/ImageIO.h>
|
||||
#import <zlib.h>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@implementation FLEXUtility
|
||||
|
||||
@@ -246,8 +247,8 @@
|
||||
// [a, 1]
|
||||
NSArray *components = [keyValueString componentsSeparatedByString:@"="];
|
||||
if ([components count] == 2) {
|
||||
NSString *key = [[components firstObject] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
id value = [[components lastObject] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
NSString *key = [[components firstObject] stringByRemovingPercentEncoding];
|
||||
id value = [[components lastObject] stringByRemovingPercentEncoding];
|
||||
|
||||
// Handle multiple entries under the same key as an array
|
||||
id existingEntry = [queryDictionary objectForKey:key];
|
||||
@@ -325,4 +326,69 @@
|
||||
return inflatedData;
|
||||
}
|
||||
|
||||
+ (SEL)swizzledSelectorForSelector:(SEL)selector
|
||||
{
|
||||
return NSSelectorFromString([NSString stringWithFormat:@"_flex_swizzle_%x_%@", arc4random(), NSStringFromSelector(selector)]);
|
||||
}
|
||||
|
||||
+ (BOOL)instanceRespondsButDoesNotImplementSelector:(SEL)selector class:(Class)cls
|
||||
{
|
||||
if ([cls instancesRespondToSelector:selector]) {
|
||||
unsigned int numMethods = 0;
|
||||
Method *methods = class_copyMethodList(cls, &numMethods);
|
||||
|
||||
BOOL implementsSelector = NO;
|
||||
for (int index = 0; index < numMethods; index++) {
|
||||
SEL methodSelector = method_getName(methods[index]);
|
||||
if (selector == methodSelector) {
|
||||
implementsSelector = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(methods);
|
||||
|
||||
if (!implementsSelector) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (void)replaceImplementationOfKnownSelector:(SEL)originalSelector onClass:(Class)class withBlock:(id)block swizzledSelector:(SEL)swizzledSelector
|
||||
{
|
||||
// This method is only intended for swizzling methods that are know to exist on the class.
|
||||
// Bail if that isn't the case.
|
||||
Method originalMethod = class_getInstanceMethod(class, originalSelector);
|
||||
if (!originalMethod) {
|
||||
return;
|
||||
}
|
||||
|
||||
IMP implementation = imp_implementationWithBlock(block);
|
||||
class_addMethod(class, swizzledSelector, implementation, method_getTypeEncoding(originalMethod));
|
||||
Method newMethod = class_getInstanceMethod(class, swizzledSelector);
|
||||
method_exchangeImplementations(originalMethod, newMethod);
|
||||
}
|
||||
|
||||
+ (void)replaceImplementationOfSelector:(SEL)selector withSelector:(SEL)swizzledSelector forClass:(Class)cls withMethodDescription:(struct objc_method_description)methodDescription implementationBlock:(id)implementationBlock undefinedBlock:(id)undefinedBlock
|
||||
{
|
||||
if ([self instanceRespondsButDoesNotImplementSelector:selector class:cls]) {
|
||||
return;
|
||||
}
|
||||
|
||||
IMP implementation = imp_implementationWithBlock((id)([cls instancesRespondToSelector:selector] ? implementationBlock : undefinedBlock));
|
||||
|
||||
Method oldMethod = class_getInstanceMethod(cls, selector);
|
||||
if (oldMethod) {
|
||||
class_addMethod(cls, swizzledSelector, implementation, methodDescription.types);
|
||||
|
||||
Method newMethod = class_getInstanceMethod(cls, swizzledSelector);
|
||||
|
||||
method_exchangeImplementations(oldMethod, newMethod);
|
||||
} else {
|
||||
class_addMethod(cls, selector, implementation, methodDescription.types);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
53874F9918F36B1800510922 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 53874F9718F36B1800510922 /* Localizable.strings */; };
|
||||
650855EB1A9007D5006109A1 /* FLEXArgumentInputDateView.m in Sources */ = {isa = PBXBuildFile; fileRef = 650855EA1A9007D5006109A1 /* FLEXArgumentInputDateView.m */; };
|
||||
65F8DC6C1A8F11020076F87B /* FLEXFileBrowserFileOperationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 65F8DC6B1A8F11020076F87B /* FLEXFileBrowserFileOperationController.m */; };
|
||||
679F6A121BD61B2400A8C94C /* FLEXCookiesTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 679F6A111BD61B2400A8C94C /* FLEXCookiesTableViewController.m */; settings = {ASSET_TAGS = (); }; };
|
||||
9421B88D1A8BBCB200BA3E46 /* FLEXNetworkHistoryTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9421B8801A8BBCB200BA3E46 /* FLEXNetworkHistoryTableViewController.m */; };
|
||||
9421B88E1A8BBCB200BA3E46 /* FLEXNetworkRecorder.m in Sources */ = {isa = PBXBuildFile; fileRef = 9421B8821A8BBCB200BA3E46 /* FLEXNetworkRecorder.m */; };
|
||||
9421B88F1A8BBCB200BA3E46 /* FLEXNetworkTransaction.m in Sources */ = {isa = PBXBuildFile; fileRef = 9421B8841A8BBCB200BA3E46 /* FLEXNetworkTransaction.m */; };
|
||||
@@ -52,6 +53,8 @@
|
||||
9421B8911A8BBCB200BA3E46 /* FLEXNetworkTransactionTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9421B8881A8BBCB200BA3E46 /* FLEXNetworkTransactionTableViewCell.m */; };
|
||||
9421B8921A8BBCB200BA3E46 /* FLEXNetworkObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = 9421B88B1A8BBCB200BA3E46 /* FLEXNetworkObserver.m */; };
|
||||
9421B8931A8BBCB200BA3E46 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 9421B88C1A8BBCB200BA3E46 /* LICENSE */; };
|
||||
942DCD8A1BAE131500DB5DC2 /* FLEXKeyboardShortcutManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 942DCD891BAE131500DB5DC2 /* FLEXKeyboardShortcutManager.m */; };
|
||||
942DCD8D1BAE819500DB5DC2 /* FLEXKeyboardHelpViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 942DCD8C1BAE819500DB5DC2 /* FLEXKeyboardHelpViewController.m */; };
|
||||
943203FE1978F42F00E24DB3 /* AAPLCatalogTableTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 943203FD1978F42F00E24DB3 /* AAPLCatalogTableTableViewController.m */; };
|
||||
944F7489197B458C009AB039 /* FLEXArrayExplorerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 944F7426197B458C009AB039 /* FLEXArrayExplorerViewController.m */; };
|
||||
944F748A197B458C009AB039 /* FLEXClassExplorerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 944F7428197B458C009AB039 /* FLEXClassExplorerViewController.m */; };
|
||||
@@ -180,6 +183,8 @@
|
||||
650855EA1A9007D5006109A1 /* FLEXArgumentInputDateView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXArgumentInputDateView.m; sourceTree = "<group>"; };
|
||||
65F8DC6A1A8F11020076F87B /* FLEXFileBrowserFileOperationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXFileBrowserFileOperationController.h; sourceTree = "<group>"; };
|
||||
65F8DC6B1A8F11020076F87B /* FLEXFileBrowserFileOperationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXFileBrowserFileOperationController.m; sourceTree = "<group>"; };
|
||||
679F6A101BD61B2400A8C94C /* FLEXCookiesTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXCookiesTableViewController.h; sourceTree = "<group>"; };
|
||||
679F6A111BD61B2400A8C94C /* FLEXCookiesTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXCookiesTableViewController.m; sourceTree = "<group>"; };
|
||||
9421B87F1A8BBCB200BA3E46 /* FLEXNetworkHistoryTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXNetworkHistoryTableViewController.h; sourceTree = "<group>"; };
|
||||
9421B8801A8BBCB200BA3E46 /* FLEXNetworkHistoryTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXNetworkHistoryTableViewController.m; sourceTree = "<group>"; };
|
||||
9421B8811A8BBCB200BA3E46 /* FLEXNetworkRecorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXNetworkRecorder.h; sourceTree = "<group>"; };
|
||||
@@ -193,6 +198,10 @@
|
||||
9421B88A1A8BBCB200BA3E46 /* FLEXNetworkObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXNetworkObserver.h; sourceTree = "<group>"; };
|
||||
9421B88B1A8BBCB200BA3E46 /* FLEXNetworkObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXNetworkObserver.m; sourceTree = "<group>"; };
|
||||
9421B88C1A8BBCB200BA3E46 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
|
||||
942DCD881BAE131500DB5DC2 /* FLEXKeyboardShortcutManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXKeyboardShortcutManager.h; sourceTree = "<group>"; };
|
||||
942DCD891BAE131500DB5DC2 /* FLEXKeyboardShortcutManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXKeyboardShortcutManager.m; sourceTree = "<group>"; };
|
||||
942DCD8B1BAE819500DB5DC2 /* FLEXKeyboardHelpViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXKeyboardHelpViewController.h; sourceTree = "<group>"; };
|
||||
942DCD8C1BAE819500DB5DC2 /* FLEXKeyboardHelpViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXKeyboardHelpViewController.m; sourceTree = "<group>"; };
|
||||
943203FC1978F42F00E24DB3 /* AAPLCatalogTableTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AAPLCatalogTableTableViewController.h; sourceTree = "<group>"; };
|
||||
943203FD1978F42F00E24DB3 /* AAPLCatalogTableTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AAPLCatalogTableTableViewController.m; sourceTree = "<group>"; };
|
||||
944F7425197B458C009AB039 /* FLEXArrayExplorerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXArrayExplorerViewController.h; sourceTree = "<group>"; };
|
||||
@@ -544,6 +553,10 @@
|
||||
944F7443197B458C009AB039 /* FLEXUtility.m */,
|
||||
94CB48371A8EC6000054A905 /* FLEXMultilineTableViewCell.h */,
|
||||
94CB48381A8EC6000054A905 /* FLEXMultilineTableViewCell.m */,
|
||||
942DCD881BAE131500DB5DC2 /* FLEXKeyboardShortcutManager.h */,
|
||||
942DCD891BAE131500DB5DC2 /* FLEXKeyboardShortcutManager.m */,
|
||||
942DCD8B1BAE819500DB5DC2 /* FLEXKeyboardHelpViewController.h */,
|
||||
942DCD8C1BAE819500DB5DC2 /* FLEXKeyboardHelpViewController.m */,
|
||||
);
|
||||
name = Utility;
|
||||
path = ../Classes/Utility;
|
||||
@@ -643,6 +656,8 @@
|
||||
944F747D197B458C009AB039 /* FLEXLibrariesTableViewController.m */,
|
||||
944F747E197B458C009AB039 /* FLEXLiveObjectsTableViewController.h */,
|
||||
944F747F197B458C009AB039 /* FLEXLiveObjectsTableViewController.m */,
|
||||
679F6A101BD61B2400A8C94C /* FLEXCookiesTableViewController.h */,
|
||||
679F6A111BD61B2400A8C94C /* FLEXCookiesTableViewController.m */,
|
||||
944F7480197B458C009AB039 /* FLEXWebViewController.h */,
|
||||
944F7481197B458C009AB039 /* FLEXWebViewController.m */,
|
||||
);
|
||||
@@ -772,6 +787,7 @@
|
||||
944F74A2197B458C009AB039 /* FLEXArgumentInputViewFactory.m in Sources */,
|
||||
944F74A1197B458C009AB039 /* FLEXArgumentInputView.m in Sources */,
|
||||
535682B618F3670300BAAD62 /* AAPLSegmentedControlViewController.m in Sources */,
|
||||
942DCD8A1BAE131500DB5DC2 /* FLEXKeyboardShortcutManager.m in Sources */,
|
||||
944F74AE197B458C009AB039 /* FLEXClassesTableViewController.m in Sources */,
|
||||
944F74B1197B458C009AB039 /* FLEXInstancesTableViewController.m in Sources */,
|
||||
944F7497197B458C009AB039 /* FLEXUtility.m in Sources */,
|
||||
@@ -817,6 +833,7 @@
|
||||
944F74AB197B458C009AB039 /* FLEXManager.m in Sources */,
|
||||
94C681F31A3E941800E1936D /* FLEXLayerExplorerViewController.m in Sources */,
|
||||
944F74B2197B458C009AB039 /* FLEXLibrariesTableViewController.m in Sources */,
|
||||
942DCD8D1BAE819500DB5DC2 /* FLEXKeyboardHelpViewController.m in Sources */,
|
||||
535682BF18F3670300BAAD62 /* UIColor+AAPLApplicationSpecific.m in Sources */,
|
||||
535682B718F3670300BAAD62 /* AAPLSliderViewController.m in Sources */,
|
||||
9421B88E1A8BBCB200BA3E46 /* FLEXNetworkRecorder.m in Sources */,
|
||||
@@ -847,6 +864,7 @@
|
||||
944F74AA197B458C009AB039 /* FLEXExplorerViewController.m in Sources */,
|
||||
944F7492197B458C009AB039 /* FLEXViewControllerExplorerViewController.m in Sources */,
|
||||
5356824A18F3656900BAAD62 /* main.m in Sources */,
|
||||
679F6A121BD61B2400A8C94C /* FLEXCookiesTableViewController.m in Sources */,
|
||||
535682B118F3670300BAAD62 /* AAPLImageViewController.m in Sources */,
|
||||
944F7493197B458C009AB039 /* FLEXViewExplorerViewController.m in Sources */,
|
||||
944F7495197B458C009AB039 /* FLEXResources.m in Sources */,
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |spec|
|
||||
spec.name = "FLEX"
|
||||
spec.version = "2.0.6"
|
||||
spec.version = "2.1.0"
|
||||
spec.summary = "A set of in-app debugging and exploration tools for iOS"
|
||||
spec.description = <<-DESC
|
||||
- Inspect and modify views in the hierarchy.
|
||||
|
||||
@@ -136,6 +136,12 @@
|
||||
3A4C95421B5B21410088C3F2 /* FLEXNetworkObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A4C94C21B5B21410088C3F2 /* FLEXNetworkObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
||||
3A4C95431B5B21410088C3F2 /* FLEXNetworkObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A4C94C31B5B21410088C3F2 /* FLEXNetworkObserver.m */; };
|
||||
3A4C95471B5B217D0088C3F2 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A4C95461B5B217D0088C3F2 /* libz.dylib */; };
|
||||
679F64861BD53B7B00A8C94C /* FLEXCookiesTableViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 679F64841BD53B7B00A8C94C /* FLEXCookiesTableViewController.h */; settings = {ASSET_TAGS = (); }; };
|
||||
679F64871BD53B7B00A8C94C /* FLEXCookiesTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 679F64851BD53B7B00A8C94C /* FLEXCookiesTableViewController.m */; settings = {ASSET_TAGS = (); }; };
|
||||
942DCD871BAE0CA300DB5DC2 /* FLEXKeyboardShortcutManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 942DCD831BAE0AD300DB5DC2 /* FLEXKeyboardShortcutManager.m */; };
|
||||
94AAF0381BAF2E1F00DE8760 /* FLEXKeyboardHelpViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 94AAF0361BAF2E1F00DE8760 /* FLEXKeyboardHelpViewController.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
||||
94AAF0391BAF2E1F00DE8760 /* FLEXKeyboardHelpViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 94AAF0371BAF2E1F00DE8760 /* FLEXKeyboardHelpViewController.m */; };
|
||||
94AAF03A1BAF2F0300DE8760 /* FLEXKeyboardShortcutManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 942DCD821BAE0AD300DB5DC2 /* FLEXKeyboardShortcutManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -271,6 +277,12 @@
|
||||
3A4C94C31B5B21410088C3F2 /* FLEXNetworkObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXNetworkObserver.m; sourceTree = "<group>"; };
|
||||
3A4C94C41B5B21410088C3F2 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
|
||||
3A4C95461B5B217D0088C3F2 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
|
||||
679F64841BD53B7B00A8C94C /* FLEXCookiesTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXCookiesTableViewController.h; sourceTree = "<group>"; };
|
||||
679F64851BD53B7B00A8C94C /* FLEXCookiesTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXCookiesTableViewController.m; sourceTree = "<group>"; };
|
||||
942DCD821BAE0AD300DB5DC2 /* FLEXKeyboardShortcutManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXKeyboardShortcutManager.h; sourceTree = "<group>"; };
|
||||
942DCD831BAE0AD300DB5DC2 /* FLEXKeyboardShortcutManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXKeyboardShortcutManager.m; sourceTree = "<group>"; };
|
||||
94AAF0361BAF2E1F00DE8760 /* FLEXKeyboardHelpViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXKeyboardHelpViewController.h; sourceTree = "<group>"; };
|
||||
94AAF0371BAF2E1F00DE8760 /* FLEXKeyboardHelpViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXKeyboardHelpViewController.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -371,6 +383,10 @@
|
||||
3A4C945C1B5B21410088C3F2 /* FLEXRuntimeUtility.m */,
|
||||
3A4C945D1B5B21410088C3F2 /* FLEXUtility.h */,
|
||||
3A4C945E1B5B21410088C3F2 /* FLEXUtility.m */,
|
||||
942DCD821BAE0AD300DB5DC2 /* FLEXKeyboardShortcutManager.h */,
|
||||
942DCD831BAE0AD300DB5DC2 /* FLEXKeyboardShortcutManager.m */,
|
||||
94AAF0361BAF2E1F00DE8760 /* FLEXKeyboardHelpViewController.h */,
|
||||
94AAF0371BAF2E1F00DE8760 /* FLEXKeyboardHelpViewController.m */,
|
||||
);
|
||||
path = Utility;
|
||||
sourceTree = "<group>";
|
||||
@@ -478,6 +494,8 @@
|
||||
3A4C94A81B5B21410088C3F2 /* FLEXLibrariesTableViewController.m */,
|
||||
3A4C94A91B5B21410088C3F2 /* FLEXLiveObjectsTableViewController.h */,
|
||||
3A4C94AA1B5B21410088C3F2 /* FLEXLiveObjectsTableViewController.m */,
|
||||
679F64841BD53B7B00A8C94C /* FLEXCookiesTableViewController.h */,
|
||||
679F64851BD53B7B00A8C94C /* FLEXCookiesTableViewController.m */,
|
||||
3A4C94AB1B5B21410088C3F2 /* FLEXWebViewController.h */,
|
||||
3A4C94AC1B5B21410088C3F2 /* FLEXWebViewController.m */,
|
||||
3A4C94AD1B5B21410088C3F2 /* SystemLog */,
|
||||
@@ -605,8 +623,11 @@
|
||||
3A4C94CD1B5B21410088C3F2 /* FLEXGlobalsTableViewControllerEntry.h in Headers */,
|
||||
3A4C94FB1B5B21410088C3F2 /* FLEXArgumentInputStringView.h in Headers */,
|
||||
3A4C95421B5B21410088C3F2 /* FLEXNetworkObserver.h in Headers */,
|
||||
679F64861BD53B7B00A8C94C /* FLEXCookiesTableViewController.h in Headers */,
|
||||
3A4C95401B5B21410088C3F2 /* FLEXNetworkTransactionTableViewCell.h in Headers */,
|
||||
3A4C95241B5B21410088C3F2 /* FLEXFileBrowserTableViewController.h in Headers */,
|
||||
94AAF0381BAF2E1F00DE8760 /* FLEXKeyboardHelpViewController.h in Headers */,
|
||||
94AAF03A1BAF2F0300DE8760 /* FLEXKeyboardShortcutManager.h in Headers */,
|
||||
3A4C94E11B5B21410088C3F2 /* FLEXResources.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -679,6 +700,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
942DCD871BAE0CA300DB5DC2 /* FLEXKeyboardShortcutManager.m in Sources */,
|
||||
3A4C95121B5B21410088C3F2 /* FLEXPropertyEditorViewController.m in Sources */,
|
||||
3A4C95391B5B21410088C3F2 /* FLEXNetworkRecorder.m in Sources */,
|
||||
3A4C950E1B5B21410088C3F2 /* FLEXIvarEditorViewController.m in Sources */,
|
||||
@@ -686,6 +708,7 @@
|
||||
3A4C94F61B5B21410088C3F2 /* FLEXArgumentInputJSONObjectView.m in Sources */,
|
||||
3A4C94EC1B5B21410088C3F2 /* FLEXImagePreviewViewController.m in Sources */,
|
||||
3A4C94F21B5B21410088C3F2 /* FLEXArgumentInputFontsPickerView.m in Sources */,
|
||||
94AAF0391BAF2E1F00DE8760 /* FLEXKeyboardHelpViewController.m in Sources */,
|
||||
3A4C951F1B5B21410088C3F2 /* FLEXClassesTableViewController.m in Sources */,
|
||||
3A4C94C61B5B21410088C3F2 /* FLEXArrayExplorerViewController.m in Sources */,
|
||||
3A4C95081B5B21410088C3F2 /* FLEXDefaultEditorViewController.m in Sources */,
|
||||
@@ -693,6 +716,7 @@
|
||||
3A4C94F01B5B21410088C3F2 /* FLEXArgumentInputDateView.m in Sources */,
|
||||
3A4C94CA1B5B21410088C3F2 /* FLEXDefaultsExplorerViewController.m in Sources */,
|
||||
3A4C94D01B5B21410088C3F2 /* FLEXImageExplorerViewController.m in Sources */,
|
||||
679F64871BD53B7B00A8C94C /* FLEXCookiesTableViewController.m in Sources */,
|
||||
3A4C94CE1B5B21410088C3F2 /* FLEXGlobalsTableViewControllerEntry.m in Sources */,
|
||||
3A4C94FE1B5B21410088C3F2 /* FLEXArgumentInputStructView.m in Sources */,
|
||||
3A4C94E01B5B21410088C3F2 /* FLEXMultilineTableViewCell.m in Sources */,
|
||||
|
||||
@@ -17,6 +17,7 @@ FLEX (Flipboard Explorer) is a set of in-app debugging and exploration tools for
|
||||
- Dynamically modify many properties and ivars.
|
||||
- Dynamically call instance and class methods.
|
||||
- Observe detailed network request history with timing, headers, and full responses.
|
||||
- Add your own simulator keyboard shortcuts.
|
||||
- View system log messages (e.g. from `NSLog`).
|
||||
- Access any live object via a scan of the heap.
|
||||
- View the file system within your app's sandbox.
|
||||
@@ -28,6 +29,9 @@ Unlike many other debugging tools, FLEX runs entirely inside your app, so you do
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
In the iOS simulator, you can use keyboard shortcuts to activate FLEX. `f` will toggle the FLEX toolbar. Hit the `?` key for a full list of shortcuts. You can also show FLEX programatically:
|
||||
|
||||
Short version:
|
||||
|
||||
```objc
|
||||
@@ -62,7 +66,7 @@ Once a view is selected, you can tap on the info bar below the toolbar to presen
|
||||

|
||||
|
||||
### Network History
|
||||
When enabled, network debugging allows you to view all requests made using NSURLConnection or NSURLSession. Settings allow you to adjust what kind of response bodies get cached and the maximum size limit of the response cache. You can choose to have network debugging enabled automatically on app launch. This setting is persisted accross launches.
|
||||
When enabled, network debugging allows you to view all requests made using NSURLConnection or NSURLSession. Settings allow you to adjust what kind of response bodies get cached and the maximum size limit of the response cache. You can choose to have network debugging enabled automatically on app launch. This setting is persisted across launches.
|
||||
|
||||

|
||||
|
||||
@@ -71,6 +75,11 @@ FLEX queries malloc for all the live allocated memory blocks and searches for on
|
||||
|
||||

|
||||
|
||||
### Simulator Keyboard Shortcuts
|
||||
Default keyboard shortcuts allow you to activate the FLEX tools, scroll with the arrow keys, and close modals using the escape key. You can also add custom keyboard shortcuts via `-[FLEXMananger registerSimulatorShortcutWithKey:modifiers:action:description]`
|
||||
|
||||

|
||||
|
||||
### File Browser
|
||||
View the file system within your app's sandbox. FLEX shows file sizes, image previews, and pretty prints `.json` and `.plist` files. You can copy text and image files to the pasteboard if you want to inspect them outside of your app.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user