Thursday, December 3, 2015

A Simple Swift iOS App from Start to Finish - Publishing my App

Introduction

This is part of a series of articles describing the creation of a simple iOS app. A complete list of the articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:





In this article I am going to describe how I published my app on the App store.


Wednesday, October 21, 2015

A Simple Swift iOS App from Start to Finish - Testing and Polishing my App

Introduction

This is part of a series of articles describing the creation of a simple iOS app. A complete list of the articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:





In this article I am going to discuss what I did to test my app and work through how I resolved some of the issues I found.


Monday, September 28, 2015

A Simple Swift iOS App from Start to Finish - Implementing the Main View's code Part 2

Introduction

This is part of a series of articles describing the creation of a simple iOS app. A complete list of the articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:





In this article I will finish implementing the code for the main view. There are two parts left to implement. Firstly I need to implement the methods that will set up the display and secondly I need to implement the methods that will react to swipe gestures.

Sunday, September 13, 2015

A Simple Swift iOS App from Start to Finish - Implementing the Edit View's Code

Introduction

This is part of a series of articles describing the creation of a simple iOS app. A complete list of the articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:





In this article I will be implementing the code for the Edit View. The Edit View will be used for two purposes within my app. Firstly, when a new thing is added to the List View the Edit View will be opened automatically to enable the user to edit the characteristics of the new thing. Secondly, the Edit View will be opened when the user selects an existing thing within the List View.

Friday, September 11, 2015

A Simple Swift iOS App from Start to Finish - Implementing the List View's code

Introduction

This is part of a series of articles describing the creation of a simple iOS app. A complete list of the articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:





In this article I will be implementing the basic list view methods to do the following:1. Adding  new  things.
2. Listing all the things that have been defined.
3. Deleting things from the list.

Monday, September 7, 2015

Create a Compound Widget for Android Lollipop: Part 4

Integrate a custom widget

This is the fourth in a four part article detailing the implementation of a compound widget for Android Lollipop. In this part I will implement my widget's programming and design interfaces.

Create a Compound Widget for Android Lollipop: Part 3

Create a class for my compound widget

This is the third in a four part article detailing the implementation of a compound widget for Android Lollipop. In this part I will implement a class to hold the code that defines my widget's behavior. I am going to start by implementing the minimum required to be able to use my widget in Android Studio's Design editor.

Create a Compound Widget for Android Lollipop: Part 2

Create a layout for a compound widget

This is the second in a four part article detailing the implementation of a compound widget for Android Lollipop. In this part I will implement the layout file for my widget. It will contain 4 sub widgets - 3 sliders  to adjust the quantity of red, green, and blue in the color and a preview area to show the color.


The orange rectangle represents the preview area and the red, green, and blue bars represent their respective color sliders. The gray rectangles represent layout elements. The outer layout will be a horizontal LinearLayout. The inner layout will hold the three color sliders and be a vertical LinearLayout.

Create a Compound Widget for Android Lollipop: Part 1

This is the first in a four part article detailing the implementation of a compound widget for Android Lollipop. A compound widget is a widget that is made up of other preexisting widgets. Typically a compound widget will hide the properties those sub widgets usually expose and expose its own custom properties instead.

The example I am going to use is to recreate the classic color picker control. The first version of this I remember seeing was on the Commodore Amiga 30 years ago.


I am going to create a simplified version of this that will set one color.


Friday, August 21, 2015

A Simple Swift iOS App from Start to Finish - Implementing the Main View's code Part 1

Introduction

This is part of a series of articles describing the creation of a simple iOS app. A complete list of the articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:





In this article I will begin implementing the code for the main view. 

Monday, August 17, 2015

A Simple Swift iOS App from Start to Finish - Creating the Edit View

Introduction

This is part of a series of articles describing the creation of a simple iOS app. A complete list of the articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:





In this article I am going to create the Edit View for my app. This is the most complex view in the app. 

The steps involved in adding my Edit View are:


Add a new View to my storyboard.
Add a navigation Item to the new view.
Add a TextField control to hold the name of the thing being edited.
Add a Segmented control to represent whether the thing will be tracked for days with or days without.
Add labels to hold the current and record days for the thing.
Add a reset button.

Sunday, July 26, 2015

A Simple Swift iOS App from Start to Finish - Creating the List View

Introduction

This is part of a series of articles describing the creation of a simple iOS app. A complete list of the articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:





In this article I am going to create my list view which will enable the user to add and remove 'things' from my app. 


The steps involved are:

Add a new TableView to my storyboard.
Add a NavigationController to my storyboard.
Add a Tap Gesture to my main view. 
Add a new TableViewController subclass for the new table view.

Sunday, June 21, 2015

A Simple Swift iOS App from Start to Finish - Creating the Main View

Introduction

This is part of a series of articles describing the creation of a simple iOS app. A complete list of the articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:





In this article I am going implement the main view of my app by customizing the View provided The Single View Application template. At this stage all my main view will contain is a single 3 line label. The app will set both the label contents and the background color of the view. I will eventually extend this view with a graphical representation of the number of days but I will leave that for a later article.

Sunday, June 14, 2015

A Simple Swift iOS App from Start to Finish - Creating the Collection Class

Introduction

This is part of a series of articles describing the creation of a simple iOS app. A complete list of the articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:





In this article I am going to create a class to encapsulate a collection of my Thing objects. My app will use this to hold all the things the user defines. The class will contain the high level interface to the data which will be stored in a local core data store. I will leave the low level core data functions in the AppDelegate class.    

Tuesday, June 9, 2015

A Simple Swift iOS App from Start to Finish - Creating the Data Model's Wrapper Class

Introduction

This is part of a series of articles describing the creation of a simple iOS app. A complete list of the articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:




In this article I am going to create the wrapper class for my Thing entity and implement the code for a calculated property called currentDayCount.

Thursday, June 4, 2015

A Simple Swift iOS App from Start to Finish - Creating the Data Model

Introduction

This is part of a series of articles describing the creation of a simple iOS app. A complete list of the articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:




In this article I am going to create the Data model for my app. Core Data provides an interface that is very similar to a relational database except it defines data in terms of entities rather than tables. My app is going to keep records for the things it is tracking and the notifications it will attach to those things. To implement this I am going to create two entities which I will call Thing and Notification.

Thursday, May 28, 2015

A Simple Swift iOS App from Start to Finish - Customizing the Launch Screen

Introduction

This is part of a series of articles describing the creation of a simple iOS app. A complete list of the articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:




In this article I am going to customize the launch screen. In previous versions of iOS the launch screen was just an image that would be imported into Xcode in much the same way as the App Icons. A different version of the image was required for every resolution and orientation of every supported device. In Xcode 6 and iOS8 this has been simplified by replacing the image files with a Interface Builder XIB file containing a view definition.


Monday, May 25, 2015

A Simple Swift iOS App from Start to Finish - Creating App Icons with InkScape

Introduction

This is part of a series of articles describing the creation of a simple iOS app. A complete list of the articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:




Xcode assigns its default icon to all new app projects. The default icon is a pattern of lines and circles on a white background. Setting a custom app icon is not essential until the publication stage. However  I am going to add it now as I will be seeing it throughout the development of my app and it adds a sense that it is a complete app and not just an example.



Sunday, May 24, 2015

A Simple Swift iOS App from Start to Finish - Refactoring the ViewController's Name

Introduction

This is part of a series of articles detailing the creation of a simple iOS app. A complete list  of articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.


I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:



The Single View Application template created a View Controller class called ViewController for me. However as I will be adding two other View Controllers to my project I want to change this class name to the slightly less generic MainViewController.

Saturday, May 16, 2015

A Simple Swift iOS App from Start to Finish - Using Source Control in Xcode 6

Introduction

This is part of a series of articles detailing the creation of a simple iOS app. A complete list  of articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:


In this article I am going to  discuss how I am going go use Xcode's  source control facility for my App.


Tuesday, May 12, 2015

A Simple Swift iOS App from Start to Finish - Creating an App Project in Xcode 6

Introduction


This is part of a series of articles detailing the creation of a simple iOS app. A complete list  of articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:



My ‘Days Without Things’ app will be a universal app that will run on both iPhone and iPad and will consist of one launch screen, five views, and one data source. I’m going create it using the Swift programming language in Xcode 6.

Sunday, May 10, 2015

A Simple Swift iOS App from Start to Finish - Planning the App

Introduction

This is part of a series of articles detailing the creation of a simple iOS app. A complete list  of articles is included in the first part A Simple Swift iOS App from Start to Finish - Introduction.

I have set up a web site for the finished app at http://DaysWithoutThings.com and you can download it free directly from the app store:



In this article I will discuss the purpose and features of my app, the platforms it will work on and the design and workflow of the app.

Sunday, May 3, 2015

A Simple Swift iOS App from Start to Finish - Introduction

Introduction

This is the first of of a series of articles detailing the creation of a simple Swift iOS app.
The aim of this series is to describe the process of creating an iOS app from planning to publication.

The app that I will develop during this series is a simple app that will mimic the "Days Without Accidents" signs that are displayed in some work places. It will enable the user to track how many days they have gone with or without arbitrary things. It will also allow the user to track the number of days until or since a date.


The user can specify which things to track. They can be anything. For example they can be things the user wants to avoid like accidents or cigarettes or things the user is hoping will happen like nice weather or a pay raise. They can also count the days until or since their birthday, wedding, or some other event.



Sunday, January 11, 2015

Using Swift Enums with Core Data

Xcode does not yet provide a direct way to use Swift enumerations as a property type in a Core Data Model.

The basic pattern to do this is to store a 'raw' value of type NSNumber in the Core Data model and extend your generated NSManagedObject class to add an additional property.

For example if your generated class file is:

import Foundation
import CoreData

@objc(MyEntity)
class MyEntity: NSManagedObject {

    @NSManaged var myPropertyRaw: NSNumber

}

You can create a separate Swift file to extend this generated class with an additional property that provides the conversion to your enumeration:

import Foundation

enum MyEnumeration:Int {
    case Value0 = 0
    case Value1 = 1
    case Value2 = 2
}

extension MyEntity {
    var myProperty: MyEnumeration {
        get {
            return MyEnumeration(rawValue: myPropertyRaw.integerValue)!
        }
        set {
            myPropertyRaw = NSNumber(integer: newValue.rawValue)
        }

    }
}

For this to work your enumeration must have an integer rawType. In the example this is just Int. Alternatively you could define it to use an integer type with a specific size - Int8, Int16, Int32 or Int64.
If you do use one of these types you will have to amend your property definition to use the right parameters:

        // Int8
        get {
            return  MyEnumeration(rawValue: dateTypeRaw.charValue)!
        }
        set {
            myPropertyRaw = NSNumber(char: newValue.rawValue)
        }

        // Int16
        get {
            return  MyEnumeration(rawValue: dateTypeRaw.shortValue)!
        }
        set {
            myPropertyRaw = NSNumber(short: newValue.rawValue)
        }

        // Int32
        get {
            return  MyEnumeration(rawValue: dateTypeRaw.intValue)!
        }
        set {
            myPropertyRaw = NSNumber(int: newValue.rawValue)
        }

        // Int64
        get {
            return  MyEnumeration(rawValue: dateTypeRaw.longLongValue)!
        }
        set {
            myPropertyRaw = NSNumber(longLong: newValue.rawValue)
        }

The ! at the end of the get's return statement unwraps the value returned by the MyEnumeration's failable initializer. This assumes you are performing some validation on the raw value so that this get method will never encounter invalid values.

You have to put the extension in a separate file because you will have to regenerate the MyEntity.Swift file anytime you make changes to your MyEntity definition in your data model.

BTW you currently have to add the @objc(MyEntity) line to the generated file manually to enable Swift to work with the generated class.