Here comes an example class that defines setters and getters - these can be seen as properties.
- Code: Select all
' this is ukPerson.NSObject
Dim sName As String
Dim iAge As Integer
Sub setName(name As String)
sName=name
Log("setter called ")
End Sub
Function name() As String
Log("getter called")
Return(sName)
End Function
Function age() As Integer
Return(iAge)
End Function
Function setAge(age As Integer)
If(age > 17) Then
iAge = age
Else
iAge = 18
End If
End Function
Here is an example how to use this class:
- Code: Select all
' this is Global
Dim thePerson As ukPerson
Event AwakeFromNib()
' assign values to the instance's properties
thePerson!name = "Udo"
thePerson!age = 16
' access values of instance's properties
Alert(thePerson!name)
Alert(thePerson!age)
End Event
The project:
Two questions to my readers:
What do you code in Objective Basic?
Why aren't you coding in Objective Basic yet?
It will be interesting to read your answers.
Keep on coding
Udo