Hi, WWDC24 videos have a lot of references to an "Image Playground" API, and the "What's New in AppKit" session even shows it in action, with a "ImagePlaygroundViewController". However, there doesn't seem to be any access to the new API, even with Xcode 16.2 beta. Am I missing something, or is that 'coming later'?
Image Playground API
You can use it right now. See the /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/ImagePlayground.framework/Versions/A/Modules/ImagePlayground.swiftmodule/arm64e-apple-macos.swiftinterface
file.
Here's my sample project for iOS. https://github.com/pookjw/ImagePlaygroundExample
How do you use the delegate? When I implement the delegate , I get an error in my AppName-Swift.h file.
I have a Swift class that I've implemented to be the delegate for ImagePlaygroundViewController. Unless there's a way to access it directly from Objective-C. I figured I'd use an intermediate Swift class and then just pass the selected image to my Objective-C view controller.
This is an AppKit app. Mostly in Objective-C, but with sprinkles of Swift and SwiftUI here and there.
I've implemented the delegate and all the required methods.
@objc public class TFImagePlaygroundManager: NSObject, ImagePlaygroundViewController.Delegate
This error is what I get:
Cannot find protocol declaration for 'ImageGenerationViewControllerDelegate'; did you mean [some other delegate]
Is it not posible to use Image Playground in a mixed Swift / Objective-C Mac AppKit app?
This is the code that's auto-generated inside my AppName-Swift.h file:
@interface TFImagePlaygroundManager : NSObject <ImageGenerationViewControllerDelegate>
- (void)imagePlaygroundViewController:(ImagePlaygroundViewController * _Nonnull)imagePlaygroundViewController didCreateImageAt:(NSURL * _Nonnull)imageURL;
- (void)imagePlaygroundViewControllerDidCancel:(ImagePlaygroundViewController * _Nonnull)imagePlaygroundViewController;
- (nonnull instancetype)initWithDelegate:(id <TFImagePlaygroundDelegate> _Nonnull)delegate OBJC_DESIGNATED_INITIALIZER;
- (void)showImagePlaygroundFromController:(NSViewController * _Nonnull)controller;
- (nonnull instancetype)init SWIFT_UNAVAILABLE;
+ (nonnull instancetype)new SWIFT_UNAVAILABLE_MSG("-init is unavailable");
@end
Hi @TapZapp,
Are you able to share a focused sample project demonstrating the error so that we can take a look?
Best,
-J