Is it possible to create a SwiftUI toolbar item that will refresh its content in response to model changes. I want to display some text in the toolbar on macOS but the Text() object does not update its content when the model changes.
Is there some other solution to achieve this for SwiftUI toolbars for macOS ?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I get a lot of heif images with diagonal lines through them when using this API to generate output files. The same files output in other formats show no signs of the same diagonal lines.
This problem only seems to occur when the input CIImage is cropped and then only for certain crop dimensions.
Can someone confirm they see the same issue - I have created a test Playground which includes two sample RAW files. You will need to change the path to the input files and also change the crop dimensions to test different combinations. It seems the diagonal lines are only caused by certain width values. See the few crop examples in the Playground. I have logged a bug with Apple (FB9096406) but it would be good to get confirmation this is a bug.
I have tried cropping with CICrop filter and CIImage.cropped(to:) APIs and get the same results.
Link to a zip file with the test playground for reproducing the issue at the following link - I can't post the actual link. Use https://
to download the file from
xxxx://duncangroenewald.com/files/CoreImageHEIFExporterBug.zip
I see some others have posted links on this forum, why is it I can't seem to do that?
Why is NSAlert.runModal() crashing when called from within the Task.init { } block ?
Is this a bug. I can upload a sample program if required.
@IBAction func start(_ sender: Any) {
isBusy = true
log("start")
Task.init {
log("sync start")
let (result, message) = await asyncObj.process(5, progress: progressCallback)
isBusy = false
log(message)
log("sync end") // Reports as running in main thread
// CRASHES HERE !
alert = self.dialogOK(question: "Some question", text: "Some thing else")
log("task end") // Reports as running in main thread
}
}
func dialogOK(question: String, text: String) -> NSAlert {
let alert = NSAlert()
alert.messageText = question
alert.informativeText = text
alert.alertStyle = .warning
alert.addButton(withTitle: "OK")
return alert //.runModal() == .alertFirstButtonReturn
}
/// This process MUST run on a background thread - it cannot run on the main thread
/// So how do I force it to run on a background thread ?
func process(_ count: Int, progress: @escaping (Double)->Void) async -> (Bool, String) {
// Still on the main thread here ??
log("1 First part on the main thread ??")
let task = Task.detached { () -> (Bool, String) in
//Thread.sleep(forTimeInterval: 0.1)
log("2 Run a loop in the background")
log(" Thread: \(Thread.isMainThread ? "UI" : "BG")")
var cnt = 0
for i in 0..<count {
Thread.sleep(forTimeInterval: 0.025)// sleep(seconds: 0.1)
log(" i: \(i)")
cnt += 1
progress (Double(cnt)/Double(count)*100)
}
log(" >>>>")
return (true, "Background task Done")
}
let result = await task.value
log("2 First part on the main thread ??")
return result
}
I am trying to create a custom CGColorSpace in Swift on macOS but am not sure I really understand the concepts.
I want to use a custom color space called Spot1 and if I extract the spot color from a PDF I get the following:
"ColorSpace<Dictionary>" = {
"Cs2<Array>" = (
Separation,
Spot1,
DeviceCMYK,
{
"BitsPerSample<Integer>" = 8;
"Domain<Array>" = (
0,
1
);
"Filter<Name>" = FlateDecode;
"FunctionType<Integer>" = 0;
"Length<Integer>" = 526;
"Range<Array>" = (
0,
1,
0,
1,
0,
1,
0,
1
);
"Size<Array>" = (
1024
);
}
);
};
How can I create this same color space using the CGColorSpace(propertyListPlist: CFPropertyList) API
func createSpot1() -> CGColorSpace? {
let dict0 : NSDictionary = [
"BitsPerSample": 8,
"Domain" : [0,1],
"Filter" : "FlateDecode",
"FunctionType" : 0,
"Length" : 526,
"Range" : [0,1,0,1,0,1,0,1],
"Size" : [1024]]
let dict : NSDictionary = [
"Cs2" : ["Separation","Spot1", "DeviceCMYK", dict0]
]
let space = CGColorSpace(propertyListPlist: dict as CFPropertyList)
if space == nil {
DebugLog("Spot1 color space is nil!")
}
return space
}
I am trying to figure out if AppKit provides any support for Async/Await when presenting ViewControllers.
Typically one has to use a completionHandler that gets called when the viewController is dismissed.
Any way to used Async/Await for achieving the same thing ?
Does anyone know where I can find an example of creating a NSView subclass with custom bindings. I need to be able to bind to the object in interface builder.
This is the only reference in Apple documents but as is often the case there appear to be no examples.
https://developer.apple.com/documentation/objectivec/nsobject/nskeyvaluebindingcreation
Topic:
Developer Tools & Services
SubTopic:
Xcode
Anyone else notice that Finder no longer shows most photos exif data when in column mode - usually it appears below the photos image.