Why this method
+ (instancetype)arrayWithNSData:(NSData *)data;
in j2obj project
https://github.com/google/j2objc/blob/master/jre_emul/Classes/IOSPrimitiveArray.h#L252
invisible for Swift3?
but the other are visible. for example this:
+ (instancetype)newArrayWithBytes:(const jbyte *)buf count:(NSUInteger)count;
Factory methods in ObjC — that is, class methods that return
instancetype
(or the actual type of the class) and start with the common name of the class — get imported to Swift as initializers.So a method
+(instancetype)arrayWithSomething:
on a class whose name includesArray
gets imported asinit(something:)
. In your case,+arrayWithNSData:
will get imported asinit(nsData:)
. (You might think it'd drop the "NS", since it'll also convert the parameter type fromNSData
to its Swift value type equivalentFoundation.Data
... but it doesn't.)To find this and other importer effects, you can see the result for yourself in Xcode by looking at the "Generated Interface" view of your source. Check the related items button at the left of the jump bar, or the assistant editor.
For more details, read about Initialization in Apple's Using Swift with Cocoa and Objective-C doc.