Identify AGSGraphicsOverlay

604
3
05-05-2017 06:19 AM
Armandvan_der_Zwan
New Contributor II

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.

Tags (1)
0 Kudos
3 Replies
RyanOlson1
Esri Contributor

Just keep a reference to the overlay you are interested in.

Nicholas-Furness
Esri Regular Contributor

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 {
    fileprivate struct AssociatedKeys {
        static var referenceNameKey = "geodev_referenceName"
    }
    
    var referenceName:String? {
        get {
            return objc_getAssociatedObject(self, &AssociatedKeys.referenceNameKey) as? String
        }
        set {
            objc_setAssociatedObject(self, &AssociatedKeys.referenceNameKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
    }
}

For more info on associated objects and Swift, see here.

Armandvan_der_Zwan
New Contributor II

Thanks.

I'm keeping a reference to them now, so I can delete them later.

0 Kudos