You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCF/CF Preferences Test
Class Window1 Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
read
End EventHandler
End Control
Control EditField1 Inherits TextField
ControlInstance EditField1 Inherits TextField
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
write
End EventHandler
End Control
Control EditField2 Inherits TextField
ControlInstance EditField2 Inherits TextField
End Control
Sub read()
dim c as CFPreferencesMBS
dim o as CFObjectMBS
dim s as CFStringMBS
c=new CFPreferencesMBS
o=c.CopyAppValue(NewCFStringMBS("test"),c.kCFPreferencesCurrentApplication)
if o isa CFStringMBS then
s=CFStringMBS(o)
if s<>Nil then
EditField1.text=s.str
else
MsgBox "A value was returned, but it's not a string!?"
end if
else
MsgBox "nil was returned -> No value found."
end if
End Sub
Sub write()
dim c as CFPreferencesMBS
dim o as CFObjectMBS
dim s as CFStringMBS
c=new CFPreferencesMBS
c.SetAppValue NewCFStringMBS("test"),NewCFStringMBS(EditField2.text),c.kCFPreferencesCurrentApplication
if c.AppSynchronize(c.kCFPreferencesCurrentApplication) then
MsgBox "Saved data."
else
MsgBox "Failed to save data."
end if
End Sub
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class