Get the current user details
Now, go to your main ViewController
which is the ViewController.swift
file under your project.
Inside the viewDidLoad()
function, get a reference to your AppDelegate
instance by adding the following line:
let appDelegate = UIApplication.shared.delegate as! AppDelegate
Now, you can easily make a call to Mitter and see the currently authenticated user details by calling the getCurrentUsers()
function on the Mitter.Users
object.
This can be done like this:
appDelegate.mitter.users.getCurrentUser {
result in
switch result {
case .success(let user):
print("Current User is: \(user)")
case .error:
print("Unable to get user!")
}
}
Now, press ⌘R
to run your project in any iPhone simulator.
If everything’s setup according to the previous steps, you should be able to see the currently authenticated user details printed to your console log inside Xcode.
Last updated