view.layer.sublayers gives you an array of sublayers to see if your layer has been added, you can do something like view.layer.sublayers.count, and as soon as the number of layers reaches what you expect, don't add more for ex .
if (view.layer.sublayers.count < 3) { //add layer }else{ // do nothing because the layer has already been added. }
You can also examine each layer in a sublevel array to better identify the layer you are looking for. Since they are properties, you should be able to compare with each of the layers in the array to see if the layer you are looking for has been added.
source share