Accessing WPF Resources on Cocoa and Island/Darwin
On Cocoa, and Island/Darwin, App resources inside a bundle are accessed at runtime by using a Cocoa API such as NSBundle.pathForResource:ofType:
(typically on the application's main bundle instance) to obtain the filename on disk. After that, regular file APIs can be used to load the file in.
var lFileName := NSBundle.mainBundle.pathForResource('MyText') ofType('txt');
var lText = File.ReadText(lFileName);
var fileName = NSBundle.mainBundle.pathForResource("MyText") ofType("txt");
var text = File.ReadText(fileName);
var fileName = NSBundle.mainBundle.pathForResource("MyText", ofType: "txt")
var text = File.ReadText(fileName);
var fileName = NSBundle.mainBundle.pathForResource("MyText") ofType("txt");
var text = File.ReadText(fileName);
Some additional APIs are provided for special resource types. For example image and icon files can also be loaded using the static NSImage.imageNamed
or UIImage.imageNamed
, on macOS or iOS, respectively.
Please refer to the Cocoa, AppKit and UIKit documentation from Apple for details.