Post

Replies

Boosts

Views

Activity

Document based Apps, how to get access to the Document from within a menu?
I am using the new MultiPlatform SwiftUI Document template in Xcode 12 and I don't understand how to get access to the current FileDocument from within a menu item. My app code looks like this (straight from the template). @main struct MyApp: App { 		var body: some Scene { 				DocumentGroup(newDocument: MyDocument()) { file in 						ContentView(document: file.$document) 				} 				.commands { 						CommandMenu("Utilities") { 								Button(action: { 										/*How to get access to the current FileDocument ?*/ 								}) { 										Text("Test") 								} 						} 				} 		} }
0
0
420
Sep ’20
JSExport based classes not released in JSContext
When I create a class using the JSExport protocol @objc protocol Font_JSExports: JSExport { 		 		var name				: String { get } } class Font					: NSObject, Font_JSExports {		 		var name				: String 		var atlas			 : MTLTexture? 		init(name: String) 		{	 				super.init() 				atlas = loadTexture( name ) 		} 		 		deinit { 				if let texture = atlas { 						texture.setPurgeableState(.empty) 						atlas = nil 				} 				print("freeing font", name) 		} } And pass this class to the javascript context via a getFont() function 		class func getFont(_ name: String) -> Font 		{ 				let list = getFonts() 				for f in list { 						if f.name == name { 								return f 						} 				} 				return list[0] 		} And get a reference to the class from javascript class Test { 		constructor() 		{ 				this.font = System.getFont("Square") 		} } The deinit destructor of the font class will never get called when I delete the JSContext. How to pass object references to JavaScript which get deallocated when the JSContext gets destructed ?
0
0
633
Sep ’20
Exhaustive list of Metal Keywords ?
Hi, is there an exhaustive list of the keywords of the Metal shading language available somewhere ? When writing syntax highlighting code it would really be nice to have one list available, instead of having to collect stuff bit by bit from all over the documentation. Thanks
0
1
515
Oct ’20
Big Sur 11 beta 10 & Xcode: Nothing is working
I installed the latest macOS Beta 10, but I cannot launch my apps from Xcode 12.2 beta 2 anymore because an instant crash: dyld`dylddebugger_notification Saw that Xcode 12.1 GM is out, downloaded it but the old problem I reported in Xcode 12 GM is back: Multiplatform apps gone from the New Project templates and existing Multiplatform apps cannot be compiled because of missing UniformTypeIdentifiers on OSX. This issue seems to only pop up in Xcode GMs but not in the betas. As Xcode 12.2 beta 2 does not work for me with Big Sur 11 beta 10 and I cannot reverse back to beta 9 my desktop setup seems to be wrecked for the moment.
3
0
1.3k
Oct ’20
How to save FileDocument based content on iOS ?
Hi, my app uses the multi-platform document based app template. All is fine on macOS, the user can manually initiate a save operation using menu or keyboard shortcuts. On iOS this is not possible, when the user clicks on the "<" symbol on the toolbar the changes in the document are lost. I guess I miss something here, am I supposed to create a save button myself ? But how ? EDIT: The default text based template works. I assume the TextEditor notifies the Document that the content changed ? On my custom document types this obviously does not work. Thanks for any feedback.
1
0
1.1k
Dec ’20
In-App Scripting
Hi, I would like to have in-app scripting support for my app and I am a bit uncertain what to use. I know there is a JS context available but JavaScript is a bit looked down upon when it comes to scripting solutions and I am also not the biggest fan. Is there any other scripting solution available which can be easily integrated with Swift and is a bit more modern and cooler ? Thanks
0
0
572
Jun ’21