Question about Objective-C and Swift interoperability. I have some Objective-C headers and implementation files which I am using in a Swift playground for a bridging project. However the Playground does not show any of my Objective-C class properties or methods of the instances of the class in the preview. I can however see properties of instances of URL, CIImage, and NSImage just fine. What step/s am I missing?
let image = CIImage(contentsOf: myUrl!) // With a url location to the image file on my disk.
The Swift Playground shows w, h beside this line.
However for my Objective-C properties of my
@interface SampleRect : NSObject
/** NSRect contains region of output pixels to render **/
@property CGRect dimensions;
-(id) init;
@end
The properties after setting the preview shows no information on the SampleRect instance.
What keyword or steps am I missing?
See the documentation for
CustomPlaygroundDisplayConvertible. Playgrounds only supports specialised displays for a limited number of types. That includesCIImage,URLetc. For other types, only a "structured description" is displayed, which is probably what you are seeing.Luckily, your
SampleRectis just a wrapper around aCGRect, so you can easily conform toCustomPlaygroundDisplayConvertibleand use the wrappedCGRectas the playground display.