iOS Tutorial - How to add ADNKit to your iOS project! (Part 2)

If you followed the previous tutorial then proceed with this tutorial to create a simple app that will post to your ADN feed.  

If you DID NOT follow the previous tutorial, this tutorial may not help out as much, but feel free to use it too.


Step 1.) Import the ADNKit headers

Make sure you import the ADNKit headers into where you will be using the ADNKit.

Should look something similar to:


Step 2.) Load your access token

If you didn't get an access token yet, go to Dev Lit to get an access token to use for this example.

With the access token, inside of your 

- (void)viewDidLoad

 load it like so:

 - (void)viewDidLoad
    [super viewDidLoad];

    // Load the access token from Dev Lite
    [ANKClient sharedClient].accessToken = @"YOUR ACCESS TOKEN GOES HERE";


Step 3.) Create a button that will send your post

In the project storyboard, drag a button object onto the view. Give it whatever text you would like. Then create an action for this button in your view controller, so that when this button is touched, it will send a post to your feed.


Step 4.) Creating your "post"

Inside of your button's action function, add the following code:

ANKPost *post = [[ANKPost alloc] init];

post.text = @"Hello, world!";

// Create the post and send it
[[ANKClient sharedClient] createPost:post completion:^(id responseObject, ANKAPIResponseMeta *meta, NSError *error) {
    if(error == nil) {
        // Display this message in the console if the post was successful.
        NSLog(@"Posted to");
    } else {
        // Display this message if there was an error when posting.
        NSLog(@"Post was not posted.");

Step 5.) Run it!

Run your app. When you click on the button, it should post "Hello, world!" to your feed!