Coding Explorer Blog

Exploring how to code for iOS in Swift and Objective-C

  • Home
  • Apps
  • About
  • Contact

Hello World! Your first iOS App in Swift

Xcode 11.6 Swift 5.2.4

Last updated on August 12, 2020

So far we’ve covered a lot of how Swift the language works, some WatchKit tutorials, and how to get started with some Cocoa classes.  However, we have not really done much in the way of actually writing sample apps on the Coding Explorer Blog.  It was covered a little bit in the WatchKit tutorials, but there is a lot done there specific to getting WatchKit working.  Let’s go all the way back to the basics, let’s write a Hello World app.

For those that don’t know, it is very common to have the first program written by somebody learning a new language be one that somehow displays “Hello World!”  At least according to Wikipedia, this goes back to an example from “The C Programming Language” book by Brian Kernighan and Dennis Ritchie.  Now, of course the simplest form of this in Swift is just:

print("Hello, World!")

But we’ll do something a bit more advanced than that.  You don’t often (or ever) see a console on your iOS device, so that doesn’t help us make an app directly.

This is a pretty basic tutorial, but I want to make it pretty comprehensive for how to start an iOS app.  This will even include going over some of the features of the IDE (integrated Development Environment), like the different editors, the utility pane, and the various inspectors therein.  This may be a bit too basic for some, but I want this site to be a place for all kinds of iOS developers, especially the beginners.  We all had to start sometime, and those are the people I want to help in particular today.

Also, I figured that it’s a new year, let’s start it with how to start a new app.
[Read more…]

Filed Under: Tutorial Tagged With: Swift

NSUserDefaults — A Swift Introduction

Xcode 11.6 Swift 5.2.4

Last updated on August 12, 2020

So, let’s say we have an app that needs to remember a few simple things that the user puts in when they first load the app.  It needs to remember the user’s name and birthday, to show on some view controller, or maybe even for a countdown on their Apple Watch.

There are plenty of ways to save data for your app.  Some are easy to use, but rather limited, while others are much harder to use, but give you a lot more capabilities.  Today, we are going to cover something on the easy, but limited end of the spectrum.  For the app mentioned above, the information we’re storing will be used to set this app up with default values, for this user anyway.

That is why this method is called NSUserDefaults.  It has its limitations, but it is very easy to use, and is ideal for simple storage of things like Strings and numbers.
[Read more…]

Filed Under: Tutorial Tagged With: optionals, Swift

Add sharing to your Swift app via UIActivityViewController

Xcode 11.6 Swift 5.2.4

Last updated on August 12, 2020

In several iOS apps, such as Safari or the Camera app, you can click a button that brings up an interface that makes it easy to send or share what you are looking at via messages, Twitter, Facebook, etc.  That interface is known as the UIActivityViewController.  When I first learned about it, I didn’t even know what to search for.  I think I originally started with “share sheet” and went on from there, so it may seem silly to point out something so obvious, but when I first tried, I knew what I wanted, I just had no idea what it was called.

If you’ve paid any attention to WWDC a few years, you have probably saw that this is the new home for Share and Action extensions.  Today though, we are just going to cover the built in aspects of using UIActivityViewController in your Swift app.  We will cover those sometime later.
[Read more…]

Filed Under: Tutorial Tagged With: Swift

  • « Previous Page
  • 1
  • 2

Subscribe to the Coding Explorer Newsletter

* indicates required

Follow Us

Facebooktwitterrss

Recent Posts

  • Error Handling in Swift
  • Creating and Modifying a URL in your Swift App
  • Watch Connectivity in Swift — Application Context
  • watchOS Hello World App in Swift
  • API Availability Checking in Swift

Categories

  • Class Reference
  • General
  • Interface Builder
  • My Apps
  • Objective-C
  • Swift
  • Syntax
  • Tutorial
  • Uncategorized

Archives

  • May 2016
  • March 2016
  • February 2016
  • December 2015
  • July 2015
  • June 2015
  • April 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • January 2014
  • November 2013
  • September 2013
  • August 2013
  • July 2013
  • Terms Of Use
  • Privacy Policy
  • Affiliate Disclaimer

Subscribe to the Coding Explorer Newsletter

* indicates required

Copyright © 2025 Wayne Media LLC · Powered by Genesis Framework · WordPress