Giter Club home page Giter Club logo

swiftui-mac's Introduction

swiftui-mac's People

Contributors

trozware avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swiftui-mac's Issues

HELP WANTED - How to save image to local disk .

I have read with great interest yours: SwiftUI for Mac.
I would like to know how to save an image on the local disk by providing a URL, for example from CoreData or more simply as in my little app:

struct ContentView: View {
    var body: some View {
        Button(action: {
            let fileUrl = URL(fileURLWithPath: "/Users/cesare/Desktop/Test", isDirectory: true)
            
            let nameImage = "ImageTest" + ".jpg"
            let fileUrlWithName = fileUrl.appendingPathComponent(nameImage)
            
            let imageData = UIImage(named: "2020-03-05_11-19-22_5")?.jpegData(compressionQuality: 1)
            do {
                try imageData!.write(to: fileUrlWithName)
            } catch {
                print("** saveImageData error: \(error.localizedDescription)")
            }
        }) {
            Text("Save Image")
        }
    }
}

which does not work, giving the following error: You don’t have permission to save the file “ImageTest.jpg” in the folder “Test”.
How should I modify the code to avoid this error which, as you wrote, it was another macOS Catalina security issue?
Obviously I configured the app as you wrote very well, without getting the desired result.
I thank you in advance for the help you can give me.

EmbeddedColorWell

EmbeddedColorWell.txt
Thanks for the articles and code examples! It has helped me immensely.

I noticed that the selectedColor in the EmbeddedColorWell is not being mutated and is not being used in a two-way manner. The selectedColor is initialized to NSColor.blue and used to set the color in the NSColorWell view. When the NSColorWell color is changed, it does change the color of the EmbeddedColorWell view. However, the actual @State var selectedColor value is never mutated in this process beyond the initialized value of NSColor.blue.

To see this, add the .background modifier to the Text as shown below:

HStack { Text("Choose a color:") .background(Color(selectedColor)) EmbeddedColorWell(selectedColor: $selectedColor) .frame(width: 44, height: 23) }

When the color is chosen in the NSColorWell, the background color does not change.

Attached is a modified version of the EmbeddedColorWell that will alter the value of selectedColor when the NSColorWell.color changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.