Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCF/Plist Parsing
Required plugins for this example: MBS MacCF Plugin, MBS MacOSX Plugin, MBS Main Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCF/Plist Parsing
This example is the version from Sun, 17th Mar 2012.
Project "Plist Parsing.rbp"
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open() dim f as FolderItem dim b as BinaryStream dim s as string dim co as CFObjectMBS dim cb as CFBinaryDataMBS dim cd as CFDictionaryMBS dim ca as CFArrayMBS dim i,c as integer dim extension as string dim iconfile as string dim name as string dim role as string dim OStypes as string if not RunningOnCarbonXMBS then MsgBox "This example is only for Mac OS X!" end if f=ApplicationsFolderMBS(-32767) f=f.Child("textedit.app") f=f.Child("Contents") f=f.Child("Info.plist") b=f.OpenAsBinaryFile(false) s=b.Read(b.Length) cb=NewCFBinaryDataMBSStr(s) co=NewCFObjectMBSFromXML(cb) cd=CFDictionaryMBS(co) // it's a dictionary as seen on the console // get subdictionary co=cd.Value(NewCFStringMBS("CFBundleDocumentTypes")) ca=CFArrayMBS(co) c=ca.Count-1 for i=0 to c co=ca.Item(i) cd=CFDictionaryMBS(co) Extension=MakeString(cd.Value(NewCFStringMBS("CFBundleTypeExtensions"))) iconfile=MakeString(cd.Value(NewCFStringMBS("CFBundleTypeIconFile"))) name=MakeString(cd.Value(NewCFStringMBS("CFBundleTypeName"))) role=MakeString(cd.Value(NewCFStringMBS("CFBundleTypeRole"))) OStypes=MakeString(cd.Value(NewCFStringMBS("CFBundleTypeOSTypes"))) List.AddRow Extension List.cell(List.LastIndex,1)=iconfile List.cell(List.LastIndex,2)=name List.cell(List.LastIndex,3)=role List.cell(List.LastIndex,4)=OStypes next End EventHandler
Function MakeString(o as cfobjectMBS) As string dim i,c as integer dim ca as CFArrayMBS dim cs as CFStringMBS dim s as string if o<>Nil then if o isa CFStringMBS then cs=CFStringMBS(o) if cs<>nil then Return cs.str end if end if if o isa CFArrayMBS then ca=CFArrayMBS(o) if ca<>nil then c=ca.Count-1 s=MakeString(ca.Item(0)) for i=1 to c s=s+", "+MakeString(ca.Item(i)) next end if end if Return s end if End Function
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
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCF Plugin.

MBS Xojo blog