Reputation: 1019
I have some wireshark logs which show characteristic read writes by handle value. I wanted to dump a map of each characteristic handle value into it's GUID representation.
I've tried using Mirror(reflecting: characteristic)
but the returned Mirror instance's children collection is empty (which is also weird since the characteristic has a bunch of public/private properties).
Unless I am misunderstanding what reflection is in Swift, I don't see what I am doing wrong. Suggestions? I really don't care about using reflection vs a different method (although one of my goals is to understand that part too).
Any hints?
Upvotes: 1
Views: 93
Reputation: 1457
It's not exactly clean, but you can invoke the private Objective-C accessor using a selector:
let res = characteristic.perform(Selector(("handle")));
let handle = res!.takeUnretainedValue() as! NSNumber;
print(handle);
Upvotes: 1