I have:
var _feedbacks: [feedBack]!
I want to add a property to [feedBack] so that I could say :
var _ID = _feedBacks.ID
I tried:
extension Array {
var ID: String {
get {
return self.ID
}
set {
self.ID = newValue
}
}
}
But the compiler throws "EXC_BAD_ACCESS"
when I tried to set/get ID
And I also tried:
import ObjectiveC
private var arrayAssocationKey: Void?
extension Array {
var ID: String {
get {
return objc_getAssociatedObject(self, &arrayAssocationKey) as? String
}
set {
objc_setAssociatedObject(self, &arrayAssocationKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_ASSIGN)
}
}
}
But the compiler calls the error `Array does not conform to protocol AnyObject
Is there any workaround to set this property?