Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSBundleMBS class.

NSBundleMBS.builtInPlugInsFolder as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname of the receiver's subdirectory containing plug-ins.
Example
MsgBox NSBundleMBS.mainBundle.builtInPlugInsFolder.DisplayName

This method returns the appropriate path for modern application and framework bundles. This method may not return a path for non-standard bundle formats or for some older bundle formats.

NSBundleMBS.builtInPlugInsPath as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname of the receiver's subdirectory containing plug-ins.
Example
MsgBox NSBundleMBS.mainBundle.builtInPlugInsPath

This method returns the appropriate path for modern application and framework bundles. This method may not return a path for non-standard bundle formats or for some older bundle formats.

NSBundleMBS.bundleFolder as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname of the receiver's bundle directory.
Example
MsgBox NSBundleMBS.mainBundle.bundleFolder.DisplayName

Some examples using this method:

NSBundleMBS.bundleIdentifier as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the receiver's bundle identifier.
Example
dim n as NSBundleMBS = NSBundleMBS.mainBundle
MsgBox n.bundleIdentifier

Returns the receiver's bundle identifier, which is defined by the CFBundleIdentifier key in the bundle's information property list.

NSBundleMBS.bundlePath as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname of the receiver's bundle directory.
Example
MsgBox NSBundleMBS.mainBundle.bundlePath

Some examples using this method:

NSBundleMBS.Constructor(path as folderitem)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates an NSBundle object that corresponds to the specified directory.
Example
dim n as new NSBundleMBS(SpecialFolder.Applications.Child("iTunes.app"))
dim d as Dictionary = n.infoDictionary
MsgBox d.Value("CFBundleName")

Creates the NSBundle object that corresponds to fullPath, or fails if fullPath does not identify an accessible bundle directory. On failure the handle property is 0.

This method allocates and initializes the returned object if there is no existing NSBundle associated with fullPath, in which case it returns the existing object.

See also:

NSBundleMBS.Constructor(path as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates an NSBundle object that corresponds to the specified directory.
Example
dim n as new NSBundleMBS("/Applications/iTunes.app")
dim d as Dictionary = n.infoDictionary
MsgBox d.Value("CFBundleName")

Creates the NSBundle object that corresponds to fullPath, or fails if fullPath does not identify an accessible bundle directory. On failure the handle property is 0.

This method allocates and initializes the returned object if there is no existing NSBundle associated with fullPath, in which case it returns the existing object.

See also:

NSBundleMBS.developmentLocalization as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the localization used to create the bundle.
Example
MsgBox NSBundleMBS.mainBundle.developmentLocalization

The returned localization corresponds to the value in the CFBundleDevelopmentRegion key of the bundle's property list (Info.plist).

NSBundleMBS.executableArchitectures as Integer()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns an array of numbers indicating the architecture types supported by the bundle's executable.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.app")
dim b as new NSBundleMBS(f)

dim lines(-1) as string

for each e as Integer in b.executableArchitectures
dim s as string
Select case e
case NSBundleMBS.NSBundleExecutableArchitectureI386
s="i386"
case NSBundleMBS.NSBundleExecutableArchitecturePPC
s="PPC"
case NSBundleMBS.NSBundleExecutableArchitecturePPC64
s="PPC 64-bit"
case NSBundleMBS.NSBundleExecutableArchitectureX86_64
s="x86 64-bit"
case 12
s="iPhone"
else
s=Str(e)
end Select
lines.Append hex(e)+": "+s
next

MsgBox Join(lines,EndOfLine)

This method scans the bundle's Mach-O executable and returns all of the architecture types it finds. Because they are taken directly from the executable, the returned values may not always correspond to one of the well-known CPU types defined in "Mach-O Architecture."

NSBundleMBS.executableFile as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname of the receiver's executable file.
Example
MsgBox NSBundleMBS.mainBundle.executableFile.NativePath

NSBundleMBS.executablePath as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname of the receiver's executable file.
Example
MsgBox NSBundleMBS.mainBundle.executablePath

NSBundleMBS.infoDictionary as dictionary

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a dictionary that contains information about the receiver.
Example
dim n as new NSBundleMBS(SpecialFolder.Applications.Child("iTunes.app"))
dim d as Dictionary = n.infoDictionary
dim lines(-1) as string

for each key as Variant in d.keys
dim value as Variant = d.Value(key)

// special handle folderitems
if value isa FolderItem then
dim f as FolderItem = value
value = f.Name
end if

lines.Append key.StringValue + " -> "+value.StringValue
next

MsgBox Join(lines,EndOfLine)

Returns a dictionary, constructed from the bundle's Info.plist file, that contains information about the receiver. If the bundle does not contain an Info.plist file, a valid dictionary is returned but this dictionary contains only private keys that are used internally by the NSBundle class. The NSBundle class may add extra keys to this dictionary for its own use.

NSBundleMBS.isLoaded as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Obtains information about the load status of a bundle.
Example
MsgBox str(NSBundleMBS.mainBundle.isLoaded) // mainbundle is always loaded

Returns true if the bundle's code is currently loaded, otherwise false.

NSBundleMBS.load as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Dynamically loads the bundle's executable code into a running program, if the code has not already been loaded.

Returns true if the method successfully loads the bundle's code or if the code has already been loaded, otherwise false.

You can use this method to load the code associated with a dynamically loaded bundle, such as a plug-in or framework. Prior to Mac OS X version 10.5, a bundle would attempt to load its code—if it had any—only once. Once loaded, you could not unload that code. In Mac OS X version 10.5 and later, you can unload a bundle's executable code using the unload method.
You don't need to load a bundle's executable code to search the bundle's resources.

NSBundleMBS.localizations as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a list of all the localizations contained within the receiver's bundle.
Example
MsgBox join(NSBundleMBS.mainBundle.localizations,EndOfLine)

Returna an array, containing strings, that specifies all the localizations contained within the receiver's bundle.

NSBundleMBS.localizedInfoDictionary as dictionary

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a dictionary with the keys from the bundle's localized property list.
Example
dim n as new NSBundleMBS(SpecialFolder.Applications.Child("iTunes.app"))
dim d as Dictionary = n.localizedInfoDictionary
dim lines(-1) as string

for each key as Variant in d.keys
dim value as Variant = d.Value(key)

// special handle folderitems
if value isa FolderItem then
dim f as FolderItem = value
value = f.Name
end if

lines.Append key.StringValue + " -> "+value.StringValue
next

MsgBox Join(lines,EndOfLine)

Returns a dictionary with the keys from the bundle's localized property list (InfoPlist.strings).

This method uses the preferred localization for the current user when determining which resources to return. If the preferred localization is not available, this method chooses the most appropriate localization found in the bundle.

NSBundleMBS.localizedStringForKey(key as string, value as string="", tableName as string="") as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a localized version of the string designated by the specified key and residing in the specified table.

key: The key for a string in the table identified by tableName.
value: The value to return if key is "" or if a localized string for key can't be found in the table.
tableName: The receiver's string table to search. If tableName is an empty string, the method attempts to use the table in Localizable.strings.

Returns a localized version of the string designated by key in table tableName. If value is nil or an empty string, and a localized string is not found in the table, returns key. If key and value are both nil, returns the empty string.

For more details about string localization and the specification of a .strings file, see "Working With Localized Strings."
Using the user default NSShowNonLocalizedStrings, you can alter the behavior of localizedStringForKey to log a message when the method can't find a localized string. If you set this default to true (in the global domain or in the application's domain), then when the method can't find a localized string in the table, it logs a message to the console and capitalizes key before returning it.
The following example cycles through a static array of keys when a button is clicked, gets the value for each key from a strings table named Buttons.strings, and sets the button title with the returned value:

NSBundleMBS.pathForImageResource(name as string) as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the location of the specified image resource file.

name: The name of the image resource file, without any pathname information. Including a filename extension is optional.

Returns the absolute pathname of the resource file or nil if the file was not found.

Image resources are those files in the bundle that are recognized by the NSImage class, including those that can be converted using the Image IO framework.

NSBundleMBS.pathForResource(name as string, extension as string) as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname for the resource identified by the specified name and file extension.

name: The name of the resource file.
extension: If extension is an empty string, the extension is assumed not to exist and the file URL is the first file encountered that exactly matches name.

Returns the full pathname for the resource file or nil if the file could not be located.

The method first looks for a matching resource file in the non-localized resource directory of the specified bundle. (In Mac OS X, this directory is typically called Resources but in iPhone OS, it is the main bundle directory.) If a matching resource file is not found, it then looks in the top level of any available language-specific ".lproj" directories. (The search order for the language-specific directories corresponds to the user's preferences.) It does not recurse through other subdirectories at any of these locations. For more details see Bundles and Localization.
The following code fragment gets the path to a plist within the bundle, and loads it into a dictionary.

See also:

NSBundleMBS.pathForResource(name as string, extension as string, subpath as string) as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname for the resource identified by the specified name and file extension and located in the specified bundle subdirectory.

name: The name of the resource file.
extension: If extension is an empty string, the extension is assumed not to exist and the file URL is the first file encountered that exactly matches name.
subpath: The name of the bundle subdirectory.

Returns the full pathname for the resource file or nil if the file could not be located.

If subpath is "", this method searches the top-level nonlocalized resource directory and the top-level of any language-specific directories. (In Mac OS X, the top-level nonlocalized resource directory is typically called Resources but in iPhone OS, it is the main bundle directory.) For example, suppose you have a Mac OS X application with a modern bundle and you specify "Documentation" for the subpath parameter. This method would first look in the Contents/Resources/Documentation directory of the bundle, followed by the Documentation subdirectories of each language-specific .lproj directory. (The search order for the language-specific directories corresponds to the user's preferences.) This method does not recurse through any other subdirectories at any of these locations. For more details see Bundles and Localization.

See also:

NSBundleMBS.pathForResource(name as string, extension as string, subpath as string, localizationName as string) as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname for the resource identified by the specified name and file extension, located in the specified bundle subdirectory, and limited to global resources and those associated with the specified localization.

name: The name of the resource file.
extension: If extension is an empty string, the extension is assumed not to exist and the file URL is the first file encountered that exactly matches name.
subpath: The name of the bundle subdirectory to search.
localizationName: The name of the localization. This parameter should correspond to the name of one of the bundle's language-specific resource directories without the .lproj extension.

Returns the full pathname for the resource file or nil if the file could not be located.

This method is equivalent to pathForResource:ofType, except that only nonlocalized resources and those in the language-specific .lproj directory specified by localizationName are searched.

There should typically be little reason to use this method—see Getting the Current Language and Locale.

See also:

NSBundleMBS.pathForSoundResource(name as string) as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the location of the specified sound resource file.

name: The name of the sound resource file, without any pathname information. Including a filename extension is optional

Returns the folderitme of the resource file or nil if the file was not found.

Sound resources are those files in the bundle that are recognized by the NSSound class. The types of sound files can be determined by calling the soundUnfilteredFileTypes method of NSSound.

NSBundleMBS.preferredLocalizations as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns an array of strings indicating the actual localizations contained in the receiver's bundle.

An array of strings, each of which identifies the a localization in the receiver's bundle. The localizations in the array are not returned in any particular order.

NSBundleMBS.privateFrameworksFolder as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname of the receiver's subdirectory containing frameworks.

This method returns the appropriate path for modern application and framework bundles. This method may not return a path for non-standard bundle formats or for some older bundle formats.

NSBundleMBS.privateFrameworksPath as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname of the receiver's subdirectory containing frameworks.

This method returns the appropriate path for modern application and framework bundles. This method may not return a path for non-standard bundle formats or for some older bundle formats.

NSBundleMBS.resourceFolder as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname of the receiving bundle's subdirectory containing resources.

NSBundleMBS.resourcePath as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname of the receiving bundle's subdirectory containing resources.

NSBundleMBS.sharedFrameworksFolder as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname of the receiver's subdirectory containing shared frameworks.

This method returns the appropriate path for modern application and framework bundles. This method may not return a path for non-standard bundle formats or for some older bundle formats.

NSBundleMBS.sharedFrameworksPath as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname of the receiver's subdirectory containing shared frameworks.

This method returns the appropriate path for modern application and framework bundles. This method may not return a path for non-standard bundle formats or for some older bundle formats.

NSBundleMBS.sharedSupportFolder as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname of the receiver's subdirectory containing shared support files.

This method returns the appropriate path for modern application and framework bundles. This method may not return a path for non-standard bundle formats or for some older bundle formats.

NSBundleMBS.sharedSupportPath as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the full pathname of the receiver's subdirectory containing shared support files.

This method returns the appropriate path for modern application and framework bundles. This method may not return a path for non-standard bundle formats or for some older bundle formats.

NSBundleMBS.unload as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Unloads the code associated with the receiver.

Returns true if the bundle was successfully unloaded or was not already loaded; otherwise, false if the bundle could not be unloaded.

This method attempts to unload a bundle's executable code using the underlying dynamic loader (typically dyld). You may use this method to unload plug-in and framework bundles when you no longer need the code they contain. You should use this method to unload bundles that were loaded using the methods of the NSBundle class only. Do not use this method to unload bundles that were originally loaded using the bundle-manipulation functions in Core Foundation.
It is the responsibility of the caller to ensure that no in-memory objects or data structures refer to the code being unloaded. For example, if you have an object whose class is defined in a bundle, you must release that object prior to unloading the bundle. Similarly, your code should not attempt to access any symbols defined in an unloaded bundle.

Prior to Mac OS X version 10.5, code could not be unloaded once loaded, and this method would always return false. In Mac OS X version 10.5 and later, you can unload a bundle's executable code using this method.

Available in Mac OS X v10.5 and later.

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


The biggest plugin in space...