So the last thing I want to be able to do is to remove all of the dice that are placed onto our sceneView 1
so that we can have a fresh start and put down as many dice as we need. So to do that, I'm going 2
to add another bar button item. 3
But while we're here, we might as well give our navigation bar a title as well. 4
Let's call it ARDicee. 5
And, of course, you can modify it if you like. 6
But for now, I'm just going to drag on a bar button item and I'm going to link it up to an IBAction 7
down here. And I'm going to call this IBAction, 8
removeAllDice. 9
Change that to an action, change the type to UIBarButtonItem, hit Connect. 10
And, again, I'm going to use one of the system icons which is the one for Trash which is a good representation 11
of deleting all of our dice. 12
All right. 13
So let's go into our ViewController and implement some code to delete all of those diceNodes from 14
our scene. 15
So, again, I'm going to say if diceArray.isEmpty is false, then we are going to loop through all 16
the dice in the diceArray. And we are going to remove each of these nodes from the parent node, so 17
removeFromParentNode. 18
All right. 19
Now, if we run our app, you can see it in its full glory. 20
And there you have it. 21
You've created a 3D dice app in augmented reality. 22
So in the next lesson, which is optional, I'm going to tidy up the code a bit and refactor some of the 23
methods. 24
This will just make it shorter, make it cleaner, make it more readable. 25
Now, there's nothing new that's happening there, 26
so it's completely optional for you to watch. 27
If you just wanted to create the dice and wanted to go and mess around with ARKit and try to do some 28
other things rendering other 3D objects into your world, then go ahead and do that. 29
So I hope you enjoy this tutorial on ARKit. 30
See you next time.