The Same Code Works Every Other Time. (Property Wrappers)

Hello everyone! I hope you are doing well.
Problem: Look, I typed some code for reviewing purposes, but it works every other time. The code, I guess, is correct and supposed to work from the first time. I initially thought that the problem might have been in frameworks, so I have tried importing Foundation and some others, the problem remained standing any way. Furthermore, I noticed that the code is runnable even without any particular framework.

Screens:
The first.


The second.

I would appreciate your explanation.

Here is the code, just in case.

@propertyWrapper struct ConfermToMe {
    var wrappedValue: String {
        didSet {
            wrappedValue = wrappedValue.uppercased()
        }
    }
    init(wrappedValue: String){
        self.wrappedValue = wrappedValue.uppercased()
    }
}

struct newStruct {
    @ConfermToMe var newValue: String
}

var me = newStruct(newValue: "How is your day going?")
print(me.newValue)

FWIW, it works every time on my machine.

You're not using anything the requires external library. @propertyWrapper is build-in to the language, and uppercased is in standard library.

1 Like

BTW, how can I know what’s built in a library via Xcode ?

Swift got only one: Swift Standard Library.

I believe Xcode also import Foundation for you in iOS project, but that's more of an exception.

That's obvious about SSL. I remember that there was an extension for Visual Studio that imports a framework automatically once you use functionality of the framework, it worked when I coded in C#. Does something like that exist in Xcode?

Terms of Service

Privacy Policy

Cookie Policy