<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">So one thing we can do in the interim until there is a sanctioned way for us to convert strings to classes and classes to strings is we can register the classes globally for transformation so that the Foundation or SwiftFoundation module name won’t be an issue.</div><div class=""><br class=""></div><div class="">By doing this early on in the initialization for NSKeyedArchiver, once of course.</div><div class=""><br class=""></div><div class=""> NSKeyedArchiver.setClassName("NSArray", forClass: NSArray.self)<br class=""> NSKeyedArchiver.setClassName("NSByteCountFormatter", forClass: NSByteCountFormatter.self)<br class=""> NSKeyedArchiver.setClassName("NSData", forClass: NSData.self)<br class=""> NSKeyedArchiver.setClassName("NSDate", forClass: NSDate.self)<br class=""> NSKeyedArchiver.setClassName("NSDateFormatter", forClass: NSDateFormatter.self)<br class=""> NSKeyedArchiver.setClassName("NSDateIntervalFormatter", forClass: NSDateIntervalFormatter.self)<br class=""> NSKeyedArchiver.setClassName("NSDecimalNumber", forClass: NSDecimalNumber.self)<br class=""> NSKeyedArchiver.setClassName("NSDictionary", forClass: NSDictionary.self)<br class=""> NSKeyedArchiver.setClassName("NSEnergyFormatter", forClass: NSEnergyFormatter.self)<br class=""> NSKeyedArchiver.setClassName("NSFormatter", forClass: NSFormatter.self)<br class=""> NSKeyedArchiver.setClassName("NSLengthFormatter", forClass: NSLengthFormatter.self)<br class=""> NSKeyedArchiver.setClassName("NSMassFormatter", forClass: NSMassFormatter.self)<br class=""> NSKeyedArchiver.setClassName("NSMessagePort", forClass: NSMessagePort.self)<br class=""> NSKeyedArchiver.setClassName("NSMutableArray", forClass: NSMutableArray.self)<br class=""> NSKeyedArchiver.setClassName("NSMutableData", forClass: NSMutableData.self)<br class=""> NSKeyedArchiver.setClassName("NSMutableDictionary", forClass: NSMutableDictionary.self)<br class=""> NSKeyedArchiver.setClassName("NSMutableSet", forClass: NSMutableSet.self)<br class=""> NSKeyedArchiver.setClassName("NSMutableString", forClass: NSMutableString.self)<br class=""> NSKeyedArchiver.setClassName("NSNotification", forClass: NSNotification.self)<br class=""> NSKeyedArchiver.setClassName("NSNumber", forClass: NSNumber.self)<br class=""> NSKeyedArchiver.setClassName("NSNumberFormatter", forClass: NSNumberFormatter.self)<br class=""> NSKeyedArchiver.setClassName("NSPersonNameComponentsFormatter", forClass: NSPersonNameComponentsFormatter.self)<br class=""> NSKeyedArchiver.setClassName("NSPort", forClass: NSPort.self)<br class=""> NSKeyedArchiver.setClassName("NSRegularExpression", forClass: NSRegularExpression.self)<br class=""> NSKeyedArchiver.setClassName("NSSet", forClass: NSSet.self)<br class=""> NSKeyedArchiver.setClassName("NSSocketPort", forClass: NSSocketPort.self)<br class=""> NSKeyedArchiver.setClassName("NSString", forClass: NSString.self)<br class=""> NSKeyedArchiver.setClassName("NSTextCheckingResult", forClass: NSTextCheckingResult.self)<br class=""> NSKeyedArchiver.setClassName("NSTimeZone", forClass: NSTimeZone.self)<br class=""> NSKeyedArchiver.setClassName("NSUUID", forClass: NSUUID.self)<br class=""> NSKeyedArchiver.setClassName("NSValue", forClass: NSValue.self)</div><div class=""><br class=""></div><div class="">I have a few more things that I was looking at for supporting this that might be useful depending on how far along you are.</div><div class=""><br class=""></div><div class="">This should give us at least a head start on the NSCoding compliant Foundation classes and user classes can come next once we have support.</div><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 23, 2015, at 3:33 PM, Luke Howard <<a href="mailto:lukeh@padl.com" class="">lukeh@padl.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><div class=""><br class="Apple-interchange-newline">On 24 Dec 2015, at 10:12 AM, Philippe Hausler <<a href="mailto:phausler@apple.com" class="">phausler@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Georgia; font-size: 18px; font-style: normal; font-variant-ligatures: normal; font-variant-position: normal; font-variant-caps: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">NSCoding will have to use something to transform from strings to classes, and that satisfy the two cases (or more) that we have already shown, currently there is no thing that does that in either form; either mangled or non mangled. Basically we need something to implement NSClassFromString with. Which we have clearly shown that dlsym does not fully meet the needs since there are cases that will emit as “module.classname” and others that emit as the mangled name. The simple case is probably going to be the a very common usage pattern for consumers (and of previously built applications). The inner class should definitely be handled in addition to this case.</div></div></blockquote><div class=""><br class=""></div><div class="">* If the mangled name is present in the archive, you can re-mangle it to get the metadata accessor</div><div class="">* If it’s a one-level unmangled name representing a class, it can be mangled</div><div class="">* If it’s a zero-level unmangled name, then it seems reasonable for a first implementation to assume it’s a SwiftFoundation class (or that the caller has set an explicit mapping)</div><div class=""><br class=""></div><div class="">Noted that dlsym() will only work with public symbols.</div><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Georgia; font-size: 18px; font-style: normal; font-variant-ligatures: normal; font-variant-position: normal; font-variant-caps: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Are there any methods that can fetch the name (either the symbolic or the readable) given a AnyClass in the runtime to get work started here? I think it is definitely sensible as a start to restrict this just to descendants of the class NSObject. I would presume that since the Metadata is potentially volatile contents we should use something along the lines of swift_getTypeName etc?</div></div></blockquote></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I have been using _typeName() but it always demangles – for interop with existing archives we need to match the behaviour of libobjc's class_getName() (equivalent to NSStringFromClass), which appears to demangle one-level classes.</span><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">— Luke</div></div></blockquote></div><br class=""></body></html>