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.


Testing the App

To being my testing I loaded my app on to a real iPad 2 and ran through adding first one thing and then after I had tested the way the main display handled that I added a couple more things and checked that the display worked as expected.
I found a few bugs that I fixed both in the source and in my previous articles. 


Memory Usage

Once I fixed the bugs I left my app running for a few hours to observe its memory usage in Xcode's debug navigator.



The good news is that there is no sign that the memory usage grows over time so I do not have any obvious memory leaks. However the memory usage does alternate between about  7MB and 9.4MB. I am not sure if this is just an effect of the debugger or something in actual app itself. I think the peaks on the memory are about three seconds apart which strongly suggests they are related to the timer triggering my displayMultipleItems method. However the longer gaps between peaks do not seem to be related to anything the app is doing.
The displayMultipleItem method does two things it retrieves a reference to a thing and then formats a message string which it assigns to the UILabel's text property.
After some trial and error I found the cause of the peaks appears to be the assignment of a new string to the message label's text property. The peaks remain even if I assign a static string to it. So at this point it seems I am not going to be able top improve this memory usage.

Polishing the App

Whilst testing my app I have noticed a few rough edges:

1. When there are no Things defined and the Main View moves automatically to the List View the main View's original green background is visible.

2. The Navigation Bar appears on the Main View.

2. On the iPad the font is huge and the messages are easily read from several feet away.

4. The name text field does not have a clear button.

5. The app name is truncated on the Home Screen.


Fixing the Main View's default background

I am going to fix this the easy way and just set the background color for both the Main View and the Launch Screen to the base shade of blue I am using in my Main View's code.


On the Main View I had so set the background color for both the view and the label. I am also going to remove the default text so the user will just see a blank screen that is the same color as the launch screen.

Fixing the Navigation Bar on the Main View

I need the Navigation Bar for the List and Edit views but do not want to see it on the Main View. To hide and show it I will override the MainView's viewWillAppear and viewWillDisappear methods and use the navigationControllers setNavigationBarHidden method to hide or show the bar.

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        navigationController?.setNavigationBarHidden(true, animated: true)
    }
    
    override func viewWillDisappear(animated: Bool) {
        super.viewWillDisappear(animated)
        navigationController?.setNavigationBarHidden(false, animated: true)
    }

Fixing the Font Size

I currently have the maximum font size set at 200 points. This is enough to fill the iPad screen which makes the messages easily read from several feet away. This may not be desirable so I am going to reduce it by half. This will still make good use of the extra screen space available on the iPad without making the messages too public.


I am also going to change the font size on the launch screen to make it consistent with the Main View.


Adding a clear button to the Name Text Field

Adding a clear button to a UITextField requires just one change in the Attributes editor.




Fixing the App Name

On the home screen my app name is being displayed as "Days Withou..." on the iPad and "Days With..." on the iPhone.


I want to change this to DaysWithout so that it will, hopefully, be displayed in full. To do this I am going to follow the instructions in this Apple technical Q&A - https://developer.apple.com/library/ios/qa/qa1823/_index.html.






More Polish

I was worried my app's functionality was not substantial enough to pass the App Store Review Guidelines so I added a couple of last minute features.

Firstly I added a graphical representation of the days tracked to the main view.



Secondly I implemented a user defined notifications system that enables the user to define local notifications for dates relative to the target day of each thing.

Wrapping up

At this point my app is complete or at least version 1 is complete. In my next article I will describe me experiences of trying to publish it in the Apps store.

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

No comments:

Post a Comment