1/3

iOS Assignment

Artist Explorer

Please conduct the following tasks alone. For implementation details you can refer to the lecture slides or the Apple developer website. Please do not hesitate to ask me or the tutor if you have any questions. Under “Tip” you can find some hints for the task. The “Checklist” specifies what should happen when your implementation is correct.

2/3

Tasks

  1. Artist Explorer
3/3

1. Artist Explorer

Implement the Artist Explorer App for iOS (with the same featureset as for Android). If you do not have an iOS device, you can create a simple array of artists yourself, that you show in the TableView.

Tip

Use the prepareForSegue() method to pass the „artist“ String to the Detail View. If you want, you can give your segue an identifier in the Interface Builder. Then you can use the following code to test if the correct segue was activated, which is necessary, if you have multiple segues:

if segue.identifier == "showDetail" {
    ...
}

To get the selected row index from the TableView, you can use:

let indexPath = self.tableView.indexPathForSelectedRow

Open the following URL to load in the WebView, attaching the artist name:

https://de.m.wikipedia.org/wiki?search=

In order to access your MusicLibrary on the phone, since iOS 10 and later, you need to set the NSAppleMusicUsageDescription key in your info.plist. You should also check if the user allowed access to the MediaLibrary before you start reading data. This can be done using the following code:


MPMediaLibrary.requestAuthorization { (status) in
            if status == .authorized {
                self.readMediaLibrary()
            } else {
                self.showError()
            }
        }

Be aware that the code that is executed in the closure does not run on the main thread. If you want to manipulate the UI (e.g. to update your tableview contents) you need to dispatch this to the main thread using the DispatchQueue (available since Swift 3.0), e.g.:


DispatchQueue.main.async {
         // your code here        }

Checklist
When the app is started all artists show up the TableView
When you select an artist the detail view is opened, showing the wikipedia entry for the selected artist