Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add present and dismiss commands for UIViewController #150

Merged
merged 1 commit into from
May 2, 2016
Merged

Add present and dismiss commands for UIViewController #150

merged 1 commit into from
May 2, 2016

Conversation

alanzeino
Copy link
Contributor

How I tested:

(lldb) expr UIViewController *$avc = (UIViewController *)[[UIViewController alloc] init]
(lldb) dismiss $avc
Traceback (most recent call last):
  File "/Users/alan/repositories/github/chisel/fblldb.py", line 79, in runCommand
    command.run(args, options)
  File "/Users/alan/repositories/github/chisel/commands/FBDisplayCommands.py", line 235, in run
    viewControllerHelpers.dismissViewController(args[0])
  File "/Users/alan/repositories/github/chisel/fblldbviewcontrollerhelpers.py", line 37, in dismissViewController
    raise Exception('Argument must be presented')
Exception: Argument must be presented
(lldb) present $avc
(lldb) c
Process 8420 resuming
(lldb) present $avc
Traceback (most recent call last):
  File "/Users/alan/repositories/github/chisel/fblldb.py", line 79, in runCommand
    command.run(args, options)
  File "/Users/alan/repositories/github/chisel/commands/FBDisplayCommands.py", line 221, in run
    viewControllerHelpers.presentViewController(args[0])
  File "/Users/alan/repositories/github/chisel/fblldbviewcontrollerhelpers.py", line 24, in presentViewController
    raise Exception('Argument is already presented')
Exception: Argument is already presented
(lldb) dismiss $avc
(lldb) c

def presentViewController(viewController):
vc = '(%s)' % (viewController)

if fb.evaluateBooleanExpression('%s != nil && ((id)[(id)%s isKindOfClass:(Class)[UIViewController class]])' % (vc, vc)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The (id) cast after the && should be (BOOL).

@alanzeino
Copy link
Contributor Author

Updated!

@kastiglione
Copy link
Contributor

🚢

@kastiglione kastiglione merged commit 1494846 into facebook:master May 2, 2016
@kastiglione
Copy link
Contributor

Thanks Xzibit

@joshavant
Copy link

Any thoughts on whether it's presently possible to push a view controller from a specific UINavigationController instance vs presenting it via UIViewController.present()?

@alanzeino
Copy link
Contributor Author

As in, to push it onto a specific UINavigationController?

It's doable, but the question is do we want a command that takes two arguments because I can't see it working without something like this:

push $nc $vc
pop $vc

(where $nc is the navigation controller and $vc is the view controller)

pop can probably omit the $nc I guess.

@joshavant
Copy link

joshavant commented Aug 30, 2016

Yes.

The use case here is that I'm trying to present a specific View Controller for debugging, as close as possible to how it would organically be presented in the app. In this particular case, the VC I'm debugging is presented in a UINavigationController (inside of a UITabBarController).

Chisel's present appears to rely on UIViewController.present() to drive its presentation, which, in practice, is different than how the VC I'm debugging will organically be presented, slightly reducing the utility of present for debugging.

If this is out-of-scope for the framework, perhaps the solution here is just dropping into the Swift REPL to accomplish this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants