objective c - Adopting NSSecureCoding with opaque types -
i have objective-c class needs adopt nssecurecoding
transport across xpc connection. class has couple properties opaque types (dispatch_queue_t
, dispatch_group_t
).
how go implementing -initwithcoder:
, -encodewithcoder:
in case? documentation says these object-like structures i'm assuming need converted to/from raw bytes when encoding/decoding? if case, i'm not sure methods should used this. option avoid encoding them @ , recreate them inside -initwithcoder:
.
there's not general solution all opaque types, mentioned dispatch_queue_t
, dispatch_group_t
. if dispatch queue , group private coded object, recreate them in -initwithcoder:
kurt revis said. if they're shared, little bit more hairy, can work around archiving "surrogate" object, traversing object graph after decoding it, replacing references surrogate references single, newly-created "real" object.
really though, sounds suspiciously anti-pattern. classes implement nscoding/nssecurecoding typically model classes, , it's kind of red flag there dispatch queues , groups in ivars of model class. can think of some legitimate reasons have private queue (i.e. serializing multithreaded access internal state) in model class ivar, not shared one. in general, sounds re-factoring might in order.
Comments
Post a Comment