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

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -