Download Multiple Files Simultaneously in iOS

On May 8, 2016, in Swift, by James Liu

Downloading multiple files concurrently is a necessary feature for a download manager app. Using UITableView is the best solution to manage multiple downloading tasks at the same time. In a table, we can maintain each separate downloading task in each table row. In this tutorial, I will use UITableView to manage all download threads. In each UITableView cells, I will put a progress bar inside to observe the downloading progress. To control the download task separately, I will also put a start button and pause button in each UITableView cell. Therefore, I will also show you how to custom UITableView cells in this tutorial.

This is the tutorial 3 of iOS download manager app tutorial. In this tutorial, I will give some example to show you how to download multiple files concurrently, and use UITableView to manage each downloading task separately. You can also access the whole tutorial series with following links:
Continue reading »


iOS CollectionView Brief Tutorial

On April 26, 2016, in Swift, by James Liu

UICollectionView is widely used in iOS apps. The most common example is the iOS photo app, which has a stylish way to display all photos in grid view or stack view. The collection view provide a simple way to let us build complicated layout by customising its cell view. Different from table view, collection view will show its cell views in grid layout. Each cell view can have different width and height. Therefore, it gives us more room to make special layout by UICollectionView.

Recently, I am going to create a file manager which will look very similar with iBooks, but will show cover and title altogether with different size. In the future, we can simply use this component in many apps, such as mp3 album app, file download manager app, or comic books app.

Start a Simple App with Collection View

Similar with UITableView and UITableViewCell, the collection view is also made up of UICollectionView and UICollectionViewCell. Additional, we can also customize the layout by setting collectionViewLayout. To build up a grid style view with UICollectionView, we can implement following delegates:

  • UICollectionViewDelegate: the delegate set up the collection view.
  • UICollectionViewDataSource: the delegate provide the data source for collection view.
  • UICollectionViewDelegateFlowLayout (optional): UICollectionView provide us a flow layout. When we use the default layout, we can use this delegate to configure the layout such as size of items and the spacing between items. We can also set collectionViewLayout as our customized layout.

Continue reading »


Save and Load Downloaded File Locally

On March 29, 2016, in Swift, by James Liu

My Download Manager app is a real project which will manage download tasks. It allow users to start download a file, pause or resume the download task, and stop a download task. In tutorial 1, I already show you all the basic functions, such as starting a download, pause, resume and stop it. However, these basic functions are really not enough. For example, if I pause the download task and quit the app, the app will lose all downloaded data.

The only solution for that is saving the downloaded data into iOS device locally when we pause the download data. So we will not lose the data even we quit the app. If we want to resume the download task, we can load the data from where we store it locally and continue to download the rest of it.
Continue reading »


Download File in iOS Start Pause and Resume

On March 28, 2016, in Swift, by James Liu

Downloading files is a common task in most of the iOS app. If you are building an ebook reader, or a comic book reader app, downloading ebooks will be a necessary feature. Last time, I am using a news reader app which will download the pdf newspaper from their website. This feature is also built in music player apps to download mp3 file, video player apps to download video file, even in the wallpaper apps to download wallpapers.
Continue reading »


XIB vs Storyboard, Which Shall I Choose in iOS Project

On March 3, 2016, in iPhone iPad Object-C, by James Liu

xib is the common way to build UI in Xcode. After Xcode 5.5, Apple introduced a new concept, storyboard. The purpose is to provide a better way to make UI simple and easy to manage. If you like, you can still use xib as your default UI editor.

When you are using xib, each UIViewController will bind with a xib. But in Storyboard, all your app screens are put together. You can use graphic interface to connect them with segues. Each way has its own pros and cons.
Continue reading »

Free WordPress Themes