Home > Uncategorized > A simple #Watchkit app in #ObjectiveC

A simple #Watchkit app in #ObjectiveC


Yes, I just got an apple watch, and the first thing I want to do with it, is to learn to program on it. so, apart from a simple “Hello World” app. I wanted to create a very simple companion app for a bitcoin app (https://itunes.apple.com/gb/app/get-bitcoin/id1072062149?mt=8)  – which just looks up the BTC / USD exchange rate and shows it on the watch.

So, here’s the code;

@interface InterfaceController()

@property (unsafe_unretained, nonatomic) IBOutlet WKInterfaceLabel *lblHello;


@implementation InterfaceController

– (void)awakeWithContext:(id)context {

    [super awakeWithContext:context];

    // Configure interface objects here.

     [self.lblHello setText:@”Loading…”];

    // make request to https://blockchain.info/tobtc?currency=USD&value=1

    NSURL *url = [NSURL URLWithString:@”https://blockchain.info/tobtc?currency=USD&value=1″];

    NSError* error;

    NSString *content = [NSString stringWithContentsOfURL:url encoding:NSASCIIStringEncoding error:&error];

    // Check for network errors

    if (error)


       [self.lblHello setText:@”Network error”];



    // Get reciprocal

    float fRate = [content floatValue];

    float fReciprocal = 1 / fRate;


    NSString *str = [NSString stringWithFormat:@”$%.2lf”, fReciprocal];


    [self.lblHello setText:str];


Categories: Uncategorized
  1. No comments yet.
  1. February 7, 2017 at 9:04 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: