How do properties work in Swift?

In Objective-C, when I declare a writeable property, the compiler generates a “set” method for that property, and I can use the “respondsToSelector” function to check if the property exists in a generic way (for example if I want to automatically set a bunch of properties from a dictionary).


In Swift this does not appear to be the case. If I just write “var name: String?” in my class, I don’t get a “setName” function that I can call.


Is the naming convention different for Swift, or does it just not use methods to set properties? If the latter, is there some other way I can set the value of a property from its name?




Powered by WPeMatico

You may also like...

Comments are closed.