Through this journey of getting to know “how to build apps for the iPhone with Swift”, I have encountered a fair share of problems. In this tutorial, I will talk about how-to display HTML  content in iOS i.e. in an iOS app. You can have a read of my previous posts on

  1. Getting started with iOS programming
  2. Serving HTML content in an iOS app
  3. Discovering Core Data migrations
  4. 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’t work i.e. the file could not be found.

Why was this a problem?

So I built the first version of my app using JQuery mobile and I thought it was all done except a few features that I would still have to add to it, once I solve all iOS specific problems. It was during this time, I met Ionic framework for building HTML5 apps. If nothing else, I so fell in love with its UI elements. Apps built with Ionic look very…native”ish” and add to that, it had a host of awesome features that I could benefit from.

How was I adding the files to my Xcode project?

Well I would drag the directory into the Xcode project and then choose the option to create group, as seen in this screenshot.

Get updates?

How-to display HTML pages in iOS

Initially I choose to search for something like, “How to refer to html files in a directory inside your Xcode project”, I failed to find a solution in a few hours. A question on StackOverflow (SO), received negative votes, seriously SO can be a little demotivating sometimes to developers trying to learn new things. Anyway since I had several other issues to solve, I decided to ignore this one and solve the other problems first, hoping that as I continue developing, my knowledge of both Xcode and iOS development will get better and I will be able to find a solution to this. I could not be more correct, the solution to my problem was really really simple. I just had to know what an Application Bundle is. Once I knew what I was dealing with, my search term changed and the solution was immediately obvious. The answer is really simple, I should not have created “Groups”, instead, I should have picked the other option and that was to “create folder references” instead. Like in the screenshot below

Other useful tutorials

In addition to this, I have written several iOS tutorials with useful code samples.

Building a native iOS Currency converter app

In this post, I will talk about my approach when building a new iOS Currency Converter. I focus on how I start by defining a simple user story, understand what the user story is followed by how I can accomplish all that technically. This post focuses on the requirements specification to build an iOS mobile app. The concepts discussed here apply to both all mobile apps, this document is focused on iOS Currency Converter. The rest of this document is structured as follows

  • iOS Currency Converter app requirements as mentioned in the assessment document
  • Define the user story for the app
  • A description of what the app will do
  • Technical requirements i.e. what libraries or frameworks can be used to achieve this
  • UI design samples for the minimal UI
  • Some backend architecture design
    • Decisions to adopt this style
  • Lastly, Questions i.e. if any aspect of building this is not clear

You can read more in the link below

Building a native iOS Currency Converter app – My Day To-Do – Bhuman (mydaytodo.com)

Tutorial on animating rows in UITableView

This post is a tutorial on how to add, delete and reload rows in UITableView with animation. Shown below is some code that I wrote for Xcode playground. This code programmatically constructs a UIButton, UITableView, adds them to a view and styles them using auto layout constraints. Then, it randomly generates a number between 1 and 3 and shows how to either,

  1. Animate inserting a new row (UITableViewCell) into a UITableView
  2. How to delete and animate removal of a row (UITableViewCell) from a UITableView
  3. How to animate reloading a section of a UITableViewRow

The code also has the necessary comments that explains some of the things. You can read the full post below.

Xcode Playground to add, delete & reload UITableView rows with animation (How-To) – My Day To-Do (mydaytodo.com)

Build your first iOS app: A Tip Calculator

Ignoring the COVID-19 world we live in right now, going out to eat is something we all love and while we don’t mind tipping the wait staff, we often don’t understand the tip calculation. Hence, I thought that helping you make a tip calculator would be the best way to get you started on making your first iOS app. Don’t worry if you haven’t built anything in iOS prior to this, with the right instructions, it’s not hard. If I can do it, so can you. The rest of this article is structured as follows,

  1. We will talk a little bit about what the app is
  2. Talk about the starter project and Xcode environment
  3. Discuss some storyboard concepts and write some code
  4. Finally, conclude with what you can do next after building this app

You can read the rest of the post in the comment below.

Building your first iOS app – Tip Calculator – My Day To-Do (mydaytodo.com)

Summary

Hope this post helped if you were stuck in a similar problem.

Get updates?

If you find any of my posts useful and want to support me, you can buy me a coffee 🙂

https://www.buymeacoffee.com/bhumansoni

Or you can  buying or even try one of my apps on the App Store. 

https://mydaytodo.com/apps/

Also, if you can leave a review on the App Store or Google Play Store, that would help too.

Categories: iOSSwift

0 Comments

Leave a Reply

Avatar placeholder
Verified by MonsterInsights