Over a million developers have joined DZone.

Getting Started With iOS for a C# Programmer - Part 2

DZone 's Guide to

Getting Started With iOS for a C# Programmer - Part 2

For those getting started with iOS, this article continues working with the code written in Part 1 and moves on to running it in a simulator.

· Mobile Zone ·
Free Resource

The purpose of this post is to take the code that we created here and run it in the simulator.

To a .Net programmer, this seems like an alien concept but, depending on the mode that you run Xcode in, it results in a different IDE. If, instead of selecting Plaground, we select "Create an Xcode Project", the whole app experience changes:

There are a lot more options available now; but let's stick to the most basic:

The created Single View App should look like this in structure:

The target of this post is simply to take the few lines of code that we wrote in part one, and have them run on a simulator.

The first thing it does is launch the ViewController, so let's take the code that we created in the first part, and add it directly to the ViewController; the new controller will look like this:

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        // Do any additional setup after loading the view, typically from a nib.

        let x = UILabel()
        x.text = "test"
        x.textColor = UIColor.black
        x.frame = CGRect(x: 5, y: 5, width: 80, height: 20)

        let v = UIView()
        v.frame = CGRect(x: 0, y: 0, width: 100, height: 100);
        v.backgroundColor = UIColor.white

        self.view = v

    override func didReceiveMemoryWarning() {
        // Dispose of any resources that can be recreated.


There are a couple of changes - firstly, we no longer reference Playground, and secondly, the active view is set here:

self.view = v

When we run this, we get the simulator appearing, and the text appears (as we might expect):

mobile ,mobile app development ,ios ,c#

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}