Skip to main content

Posts

Making an iOS app like making a Java web app - Part 2: writing iOS apps

In part 1 , I gave a brief, very high level overview on how Java web apps are written. Ok how about a quick recap of what was covered in part 1...actually let's use some diagrams this time. Previously ... in Part 1 Java web app architecture The above diagram essentially summarises what was written in the section titled " Java web app walkthrough", so in a nutshell For a Java web app, the user interface (UI) is created via HTML/CSS/Javascript The Controllers i.e. Java code act as a communication layer between the UI and the Data store, typically a Database: what that means is that the Java code passes data to and from the UI and the Data Store(Database). The kind of Data Store that I normally work with is a  relational database , there is a reason I have mentioned the type of database, read on to find out why. Refer to Part 1 for a more detailed walkthrough of a real-world example of using a registration form Now how can we apply the above approach to w...

Making an iOS app like making a Java web app - Part 1: writing Java web apps

One of the outcomes of my work on my first iOS app is my Github repository Html5StarterAppWithSwift which is an Xcode project template for creating Html5/iOS apps, or maybe we can call it "native Html5 iOS apps"... hmm what do I mean? What I mean is, it's an Xcode project template, that can help you create native iOS apps such that all of the app's UI is powered by Html/Javascript, while it makes use of native iOS code ( Swift ) for scheduling local notifications, storing data ( Core Data ) etc. p.s. if you would like to know about Html5StarterAppWithSwift , you can have a read of this post . So what is this post about? I have a background in writing  Java  web apps i.e. for my day job, I write Java web apps using frameworks such as Struts , Play  etc and there is a way in which those Java web apps are written. Now, when I started working on my first iOS app, my Java developer background played a big part in the way I structured my app i.e. separation of code...

Building my first mobile app: the journey so far - Part 2: App inception

In this post , I shed some light on the background and the circumstances leading upto my App( iOS ) and in this post, I will talk about when I first got the idea and for the App i.e. App Inception and my recovery. So for those who have not read part 1 of the series, basically what happened was, I am a Software engineer who lived a pretty good life, until one day I was a victim of a hit and run car accident. I was a pedestrian crossing the road, when a drunk driver ran a red light and hit me, left me for dead and ran away. I was eventually rescued by the paramedics and amongst other things, I suffered from a Traumatic brain injury and things fell apart. There is tragedy in my story, even though it's not quite like Okonkwo's story , it's tragedy none the less and my story is still going and good things are starting to happen. App inception So as I said, few months post injury, I had a break-up with my now ex-girlfriend, what that meant was that my family had to live...

Getting the dayBefore and dayAfter from NSDate (in Swift)

So before I write part 2 of the story of how my first mobile( iOS ) app came to be, this would be a small post on how to use Extensions in Swift, to make code more readable...amongst other things. Problem So in my iOS app, there are a few places where I have to get the day before(yesterday) and the day after(tomorrow) for a date.  Solution In the first version of my code, I had the code such as this (Read on to find out a more correct solution for calculating dates) For the day after let oneDay:Double = 60 * 60 * 24 return self.dateByAddingTimeInterval(oneDay) For the day before let oneDay:Double = 60 * 60 * 24 return self.dateByAddingTimeInterval(-(Double(oneDay))) one day has 24 hours, each hour has 60 mins and each minute has 60 seconds, so 60 * 60  * 24 to calculate the solution to my problem. This was working and it was all fine...until I delved deeper into Swift(by reading this  ebook  by Apple) and found out about Extensions!!! It ...

Building my first mobile app: the journey so far - Part 1: The background

So I have made references to my iOS app in a lot of my previous posts, if you refer to my post on Why can't I cancel a local notification in my iOS app? (in Swift) , it mentions some of the posts that I have written on how I have solved some of the problems that I have come across. It's been a year since I have been working on the app and now that I am close to finishing it, I thought I would write a little bit about the background of how this app came to be. Prelude: the land of blue skies and sunshine The year was 2013 and these were some of the key aspects of my life, I was a bit of a fast talker and people often told me, my English ascent was pretty flat for a man from India I kept fit and I did regular runs with each run being over 8-10 km I had a very loving girlfriend and we had plans to get engaged to be married in 2014 I had a job that I loved and enjoyed After years of living in a place sharing with flatmates and all, I was finally living in my own apart...

Getting the user's permission to send them local notifications in iOS (using Swift)

Ok for iOS devices I think it will still be at least another year, till we have devices that are using versions earlier than iOS 8 ! so what does that mean? Problem Well, it means that if we are building an iOS app that works on both iOS 7 and 8 which uses a feature introduced in iOS 8, we need to check if that feature exists on the device before using it. Now the iOS app that I am building uses local notifications and in iOS 8 Apple introduced this feature to ask the user to receive LOCAL NOTIFICATIONS via   registerUserNotificationSettings . So what I wanted to do is check if the feature exists on the device the app is running on without checking the iOS version on the device via  UIDevice.currentDevice().systemVersion . Solution So turns out NSObject has this really useful method called instancesRespondToSelector , so I can solve my problem of finding out the presence of registerUserNotificationsSettings using the following code, UIApplication.instancesRespon...

The importance of unit tests and how I realised it?

So my first iOS  app is nearly complete; by nearly complete, I mean it is a working app that I am using on a daily basis. I plan to use it for another two weeks or so, and see if can break any app feature in my daily usage. This is also a time when I have added every major feature to the app and what I do from time and again these days is a minor UI fix or optimise some of my earlier iOS code. You see, I started working on this app over a year ago and in that time, my knowledge of iOS programming has grown, I know more now, and I often find myself realising that there is certain code in my app that could be better written. So I go ahead with the re-write if it is nothing too major. One potential risk/side-effect of a minor UI fix or code optimisation is that I often end up breaking other app features. What have I learned? Well at this point I realise that had I written a bunch of unit tests in the beginning, testing the app after every minor fix or optimisation would have bee...