Posts

Showing posts from October, 2014

Xcode starter project with the Ionic HTML5 framework using Swift

I mentioned in one of my previous posts, about how I thought the Ionic framework for building HTM5 apps was totally awesome. Well it is and the way I was trying to use it was to build a Hybrid iOS app. Ok, when I say hybrid, I mean the logic for the app is almost equally split between both native code and HTML5 code. Why Hybrid app? So the question is, without knowing any native iOS code, how did I come to the conclusion to build a hybrid app? Ok so apparently you can make a fully HTML5 app and use the Apache Cordova framework to build an iOS app without getting your hands dirty with native code, that sounds awesome! However, to me it was important to understand native code, just in the event that something goes wrong in the app and I need to fix it by tweaking native code, I am not completely clueless about how to go about fixing it. So in an attempt to know more about iOS internals, I started off by building simple native programs(apps?) using Swift with Xcode 6 beta at the ti...

Displaying HTML content stored in a folder within an iOS app

Image
Through this journey of getting to know "how to build apps for the iPhone with Swift", I have encountered a fair share of problems. You can have a read of my previous posts on Getting started with iOS programming Serving HTML content in an iOS app Discovering Core Data migrations And  how to deal with Core Data migrations  to get an idea of the sort of problems I have faced. In this post, I am going to share about a rather simple issue that I encountered very early when I started building my app. The app I am building is an HTML5 app, actually no; A more accurate statement for this would be that it is a hybrid app, as the logic is almost equally distributed between native code and HTML5 code. Problem The problem I had was that when I would add a folder to my iOS app with web content and tried to refer to it using let path = NSBundle.mainBundle().pathForResource("index", ofType: "html", inDirectory:"webContent") It simply wouldn...

Dealing with Core data migration(lightweight) in an iOS app written in Swift

Image
So a while ago, I wrote on how I discovered the existence of this thing call Core Data migrations, by having my app crash when I added a new entity to my core data model . So the solution to that is actually not very hard, the only issue I had was that a majority of the solutions out there, deal with it in apps built with Objective-C and I needed a solution in Swift. I am not very surprised by this given how new Swift is. Problem I have defined the problem in mode detail in one of my previous  post s, its a small post and I would suggest having a read of it to better understand the problem. Anyway in a nutshell, I was working on my iOS app which used Core data, so I added an entity to my data model, deployed the app, it was saving and retrieving data and it was all working fine. Then I added another entity to my data model and then the app crashed. So then I was looking for a solution to why my app was crashing and what I can do to fix it. Solution Once again in a nutshell th...

My app crashes when I add a new entity to the core data model in my iOSapp

Ok so I was looking for a way to store data to persistent storage in my app. Since I am building an HTML5 app, my first solution was to store data using the now deprecated WebSql database ( indexedDB was only introduced in iOS 8!).  Now i had the basic data storage going and then I realised some of the storage limitations in the WebSql database, so I began searching for another solution and during that search I met  Core Data !! It was almost like love at first sight, it had all the storage awesomeness that I was after. Since there was so much love, I just wanted to build something and see how it works. So I followed an online tutorial rather than reading Apple's documentation on it, what I did was,  I added an entity to my core data model and wrote the logic to store data and it was all working! So now my app could store and retrieve data from a persistent data source without the storage limitation imposed by WebSql in a webView. It was all going great and thanks...

Modifying scope variables outside it's AngularJS controller

So, work involves a fair bit of AngualrJS  from time and again and for the most part, I am lucky enough to work with pure AngularJS code, however there are times that I have to work with non-AngularJS code that is supposed to interact with AngularJS code. Please have a look at the example below to get a clearer picture of what scenario I am talking about. Now AngularJS is awesome, but it was not always around i.e. it was released recently compared to some other Javascript libraries. So at times, integrating it with an application that already has well-written javascript, can be a bit challenging. So you may think, why angular is being added to something that already has well-written javascript code? To be honest, I do not know the exact answer to this, but if I were to guess, I suppose it would be to "leverage" some of the benefits that come from using angular. Scenario Say we have an input element in the container that we name TestCtrl, as follows ...