swift - Why iOS SDK does not encapsulate all of its library data members? -


in world of java , android class has getters , setters access , mutate data members.

however, in swift , ios development see pattern of development different used to.

ios sdk tends allow access , mutation directly many of data members (properties).

example in java , android:

textview.settext("android development");  string atext = textview.gettext(); 

example in swift , ios:

label.text = "" let atext = label.text 

as can see, ios sdk provides direct access properties.

there no difference in example. in second case (swift code) called methods func settext(text: string) , func text() -> string

this sugar developers. read please properties in swift or objective-c.

each property (that has readwrite permissions) create 2 methods: 1 setting , 1 getting data. practically there no difference in code.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -