Posts

Showing posts from September, 2014

Optional types in Swift

At work, I code in either Java, Javascript (AngularJS, Node.js) or CSS via bootstrap, so when I am coding in Swift, it is strictly something I do in my free time. Hence I make a point to keep notes of stuff that I learn which can potentially serve as a future reference for me. Swift (Apple's new programming language), allows for the presence  optional type or optionals . This concept is very well explained in this Ray Wanderlich podcast , at time 27:03 (mins:secs). As mentioned in that podcast,  the designers of Swift decided to ensure that you have no null ( nil ) references in your code. So in languages such as Java, say you have an object called person which represents a person , that has information about where the person lives i.e. address property. There is some more detail in where the person lives i.e. the name of the street i.a. street property. So now if we want to what street the person lives on, you would do person.address.street . That way you tr...

Serving HTML content in an iOS app that works in iOS 7 and later (using Swift)

As I have mentioned in an earlier post , I really enjoying coding in Swift. Now what am I doing with it? Well I am trying to build an HTML5 app that must work on devices with iOS 7. So in iOS8 apple has introduced a whole bunch of features that facilitate easy communication between web content and lets just call it back-end Swift code, but those features are not in iOS 7. So why do I want to build something that would work in an older OS? well I do not expect existing iOS users to upgrade to iOS 8 straight away and i also know a couple of people who would be very reluctant to upgrade their iPhones to iOS 8. Now in case you do not, you can have a read of the "Working with WebViews" section of this post , to know how to serve HTML content with WebViews. So when I started building my app, I wanted to know: How do I invoke some Swift code from my HTML content? Well the solution to this may feel a little bit "hacky" but it is a solution to achieve this.  The followi...

Getting started with iOS programming using Swift (Part 1)

I have not been too fond of Objective-C, which was the primary reason for me to stay away from making iOS apps till now. So what changed? Well Apple has done something very interesting recently and that is the introduction of a new programming language i.e. Swift. Swift is awesome, it almost feels like Python, C++ and Objective-C had a baby with some of their good parts in them. So I have been getting to know Swift and it is an awesome language to program in. What I am going to share with this and a series of blog posts are solutions to some problems that i have encounter while i am trying to finish my first iOS app. The one hurdle that I have encountered while getting started on developing an iOS app is that a majority of the solutions for iOS specific problems provide solutions to them using Objective-C. Which is fair, because Swift has not been around for that long. Anyway let us get started with a few basics, A few basics I would highly recommend having a read of this book...