Platforms to show: All Mac Windows Linux Cross-Platform

/MacCloud/NSFileCoordinator Test


Required plugins for this example: MBS MacCloud Plugin, MBS Main Plugin

Last modified Fri, 5th Sep 2024.

You find this example project in your MBS Xojo Plugin download as a Xojo project file within the examples folder: /MacCloud/NSFileCoordinator Test

Download this example: NSFileCoordinator Test.zip

Project "NSFileCoordinator Test.xojo_binary_project"
Class App Inherits DesktopApplication
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits DesktopWindow
Control OpenButton Inherits DesktopButton
ControlInstance OpenButton Inherits DesktopButton
EventHandler Sub Pressed() dim ofd as new OpenFileDialog dim f as FolderItem = ofd.ShowModal(Self) if f = nil then return #if TargetMacOS or TargetIOS then dim fp as new NSFilePresenterMBS dim fc as new MyNSFileCoordinatorMBS(fp) AddHandler fc.coordinateReadingItemAtURL, AddressOf coordinateReadingItemAtURL // don't ask other apps to save change dim error as NSErrorMBS dim flags as integer = NSFileCoordinatorMBS.NSFileCoordinatorReadingWithoutChanges fc.coordinateReadingItemAtURL(f, flags, error) if error <> nil then MessageBox error.localizedDescription end if #else // Windows and Linux skip this ReadTheFile file #endif End EventHandler
End Control
Sub ReadTheFile(file as FolderItem) dim b as BinaryStream = BinaryStream.Open(file) dim Data as string = b.Read(b.Length) MessageBox "Read file with "+data.Bytes.ToString+" bytes" End Sub
Sub coordinateReadingItemAtURL(N as NSFileCoordinatorMBS, url as string, file as folderitem, tag as Variant) // we got access ReadTheFile file End Sub
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
MenuItem HelpMenu = "&Help"
End MenuBar
Sign
End Sign
Class MyNSFileCoordinatorMBS Inherits NSFileCoordinatorMBS
Sub Destructor() Break End Sub
End Class
End Project

Download this example: NSFileCoordinator Test.zip

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


The biggest plugin in space...