How can I be notified when a layer has finished loading or failed to load? Previously, there were the layerDidLoad: and layer:didFailToLoadWithError: methods of the AGSLayerDelegate protocol. One could adopt that protocol and set a layer's delegate to be notified. How can this be accomplished in Quartz?
Solved! Go to Solution.
In Runtime v100, the Loadable Pattern is key. There's a great section in the Guide that talks about Loadable Resources: Loadable pattern for asynchronous resources—ArcGIS Runtime SDK for iOS | ArcGIS for Developers
So let's say you have a layer, you can check that it's loaded or failed to load with code like this (Swift 3 syntax):
layer.load() { error in
guard error == nil else {
// The layer failed to load
print("Error loading the layer \(error?.localizedDescription)")
return
}
// Now the layer has loaded and we can do something here.
print("Layer \(layer.name) loaded OK!")
}
A really neat aspect of this is that you can call ".load()" multiple times with multiple handlers and they'll all get called when the resource loads. In addition, if the resource has already loaded, the handler will just get called immediately. That's all described in more detail at the above link.
In Runtime v100, the Loadable Pattern is key. There's a great section in the Guide that talks about Loadable Resources: Loadable pattern for asynchronous resources—ArcGIS Runtime SDK for iOS | ArcGIS for Developers
So let's say you have a layer, you can check that it's loaded or failed to load with code like this (Swift 3 syntax):
layer.load() { error in
guard error == nil else {
// The layer failed to load
print("Error loading the layer \(error?.localizedDescription)")
return
}
// Now the layer has loaded and we can do something here.
print("Layer \(layer.name) loaded OK!")
}
A really neat aspect of this is that you can call ".load()" multiple times with multiple handlers and they'll all get called when the resource loads. In addition, if the resource has already loaded, the handler will just get called immediately. That's all described in more detail at the above link.
Nicholas is correct. The other thing is with Quartz you may not need to know when your layer loads - depending on why you were listening for the load delegate. If it was for authentication purposes then the new AGSAuthenticationManager will handle that for you.