0
1
00:00:00,750 --> 00:00:07,320
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

2
00:00:07,320 --> 00:00:13,770
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

3
00:00:13,770 --> 00:00:15,770
to add another bar button item.
3

4
00:00:15,810 --> 00:00:20,060
But while we're here, we might as well give our navigation bar a title as well.
4

5
00:00:20,080 --> 00:00:22,050
Let's call it ARDicee.
5

6
00:00:24,710 --> 00:00:26,840
And, of course, you can modify it if you like.
6

7
00:00:26,840 --> 00:00:33,350
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

8
00:00:33,410 --> 00:00:37,380
down here. And I'm going to call this IBAction,
8

9
00:00:37,550 --> 00:00:41,600
removeAllDice.
9

10
00:00:41,600 --> 00:00:47,280
Change that to an action, change the type to UIBarButtonItem, hit Connect.
10

11
00:00:47,390 --> 00:00:53,990
And, again, I'm going to use one of the system icons which is the one for Trash which is a good representation
11

12
00:00:54,020 --> 00:00:57,060
of deleting all of our dice.
12

13
00:00:57,110 --> 00:00:57,440
All right.
13

14
00:00:57,460 --> 00:01:04,460
So let's go into our ViewController and implement some code to delete all of those diceNodes from
14

15
00:01:04,520 --> 00:01:05,210
our scene.
15

16
00:01:05,600 --> 00:01:17,600
So, again, I'm going to say if diceArray.isEmpty is false, then we are going to loop through all
16

17
00:01:17,600 --> 00:01:30,020
the dice in the diceArray. And we are going to remove each of these nodes from the parent node, so 
17

18
00:01:32,050 --> 00:01:34,820
removeFromParentNode.
18

19
00:01:34,870 --> 00:01:35,170
All right.
19

20
00:01:35,440 --> 00:02:00,880
Now, if we run our app, you can see it in its full glory.
20

21
00:02:00,970 --> 00:02:01,960
And there you have it.
21

22
00:02:02,020 --> 00:02:06,640
You've created a 3D dice app in augmented reality.
22

23
00:02:06,640 --> 00:02:12,400
So in the next lesson, which is optional, I'm going to tidy up the code a bit and refactor some of the
23

24
00:02:12,400 --> 00:02:13,260
methods.
24

25
00:02:13,270 --> 00:02:16,930
This will just make it shorter, make it cleaner, make it more readable.
25

26
00:02:16,960 --> 00:02:18,990
Now, there's nothing new that's happening there,
26

27
00:02:19,000 --> 00:02:21,440
so it's completely optional for you to watch.
27

28
00:02:21,610 --> 00:02:27,250
If you just wanted to create the dice and wanted to go and mess around with ARKit and try to do some
28

29
00:02:27,310 --> 00:02:31,870
other things rendering other 3D objects into your world, then go ahead and do that.
29

30
00:02:32,080 --> 00:02:34,450
So I hope you enjoy this tutorial on ARKit.
30

31
00:02:34,450 --> 00:02:35,250
See you next time.
