How can I identify an AGSGraphicsOverlay?
There are no properties to do so, like attributes.
For instance, I want to disable or remove it. Do I need to keep a reference to it?
Armand.
Just keep a reference to the overlay you are interested in.
Yep. I agree. Keeping a reference is usually the right approach.
In very rare cases I've found the need to pass AGSGraphicsOverlay objects around and not necessarily know where they came from or who they belonged to but still know a little about them. In that case you could extend the AGSGraphicsOverlay class something like this:
extension AGSGraphicsOverlay <SPAN class="punctuation token">{</SPAN> fileprivate struct AssociatedKeys <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">static</SPAN> <SPAN class="keyword token">var</SPAN> referenceNameKey <SPAN class="operator token">=</SPAN> <SPAN class="string token">"geodev_referenceName"</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">var</SPAN> referenceName<SPAN class="punctuation token">:</SPAN>String<SPAN class="operator token">?</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">get</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="token function">objc_getAssociatedObject</SPAN><SPAN class="punctuation token">(</SPAN>self<SPAN class="punctuation token">,</SPAN> <SPAN class="operator token">&</SPAN>AssociatedKeys<SPAN class="punctuation token">.</SPAN>referenceNameKey<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN><SPAN class="operator token">?</SPAN> String <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">set</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="token function">objc_setAssociatedObject</SPAN><SPAN class="punctuation token">(</SPAN>self<SPAN class="punctuation token">,</SPAN> <SPAN class="operator token">&</SPAN>AssociatedKeys<SPAN class="punctuation token">.</SPAN>referenceNameKey<SPAN class="punctuation token">,</SPAN> newValue<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">.</SPAN>OBJC_ASSOCIATION_RETAIN_NONATOMIC<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
For more info on associated objects and Swift, see here.
Thanks.
I'm keeping a reference to them now, so I can delete them later.
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.