Class: NSBundle
Overview
An NSBundle object represents a location in the file system that groups code and resources that can be used in a program. NSBundle objects locate program resources, dynamically load and unload executable code, and assist in localization. You build a bundle in Xcode using one of these project types: Application, Framework, plug-ins.
Class Method Summary (collapse)
-
+ allBundles
Returns an array of all the application’s non-framework bundles.
-
+ allFrameworks
Returns an array of all of the application’s bundles that represent frameworks.
-
+ bundleForClass:
Returns the NSBundle object with which the specified class is associated.
-
+ bundleWithIdentifier:
Returns the previously created NSBundle instance that has the specified bundle identifier.
-
+ bundleWithPath:
Returns an NSBundle object that corresponds to the specified directory.
-
+ bundleWithURL:
Returns an NSBundle object that corresponds to the specified file URL.
-
+ mainBundle
Returns the NSBundle object that corresponds to the directory where the current application executable is located.
-
+ pathForResource:ofType:inDirectory:
Returns the full pathname for the resource file identified by the specified name and extension and residing in a given bundle directory.
-
+ pathsForResourcesOfType:inDirectory:
Returns an array containing the pathnames for all bundle resources having the specified extension and residing in the bundle directory at the specified path.
-
+ preferredLocalizationsFromArray:
Returns one or more localizations from the specified list that a bundle object would use to locate resources for the current user.
-
+ preferredLocalizationsFromArray:forPreferences:
Returns the localizations that a bundle object would prefer, given the specified bundle and user preference localizations.
-
+ URLForResource:withExtension:subdirectory:inBundleWithURL:
Creates and returns a file URL for the resource with the specified name and extension in the specified bundle.
-
+ URLsForResourcesWithExtension:subdirectory:inBundleWithURL:
Returns an array containing the file URLs for all bundle resources having the specified filename extension, residing in the specified resource subdirectory, within the specified bundle.
Instance Method Summary (collapse)
-
- builtInPlugInsPath
Returns the full pathname of the receiver's subdirectory containing plug-ins.
-
- builtInPlugInsURL
Returns the file URL of the receiver's subdirectory containing plug-ins.
-
- bundleIdentifier
Returns the receiver’s bundle identifier.
-
- bundlePath
Returns the full pathname of the receiver’s bundle directory.
-
- bundleURL
Returns the full URL of the receiver’s bundle directory.
-
- classNamed:
Returns the Class object for the specified name.
-
- developmentLocalization
Returns the localization used to create the bundle.
-
- executableArchitectures
Returns an array of numbers indicating the architecture types supported by the bundle’s executable.
-
- executablePath
Returns the full pathname of the receiver's executable file.
-
- executableURL
Returns the file URL of the receiver's executable file.
-
- infoDictionary
Returns a dictionary that contains information about the receiver.
-
- initWithPath:
Returns an NSBundle object initialized to correspond to the specified directory.
-
- initWithURL:
Returns an NSBundle object initialized to correspond to the specified file URL.
-
- isLoaded
Obtains information about the load status of a bundle.
-
- load
Dynamically loads the bundle’s executable code into a running program, if the code has not already been loaded.
-
- loadAndReturnError:
Loads the bundle’s executable code and returns any errors.
-
- localizations
Returns a list of all the localizations contained within the receiver’s bundle.
-
- localizedInfoDictionary
Returns a dictionary with the keys from the bundle’s localized property list.
-
- localizedStringForKey:value:table:
Returns a localized version of the string designated by the specified key and residing in the specified table.
-
- objectForInfoDictionaryKey:
Returns the value associated with the specified key in the receiver's information property list.
-
- pathForAuxiliaryExecutable:
Returns the full pathname of the executable with the specified name in the receiver’s bundle.
-
- pathForResource:ofType:
Returns the full pathname for the resource identified by the specified name and file extension.
-
- pathForResource:ofType:inDirectory:
Returns the full pathname for the resource identified by the specified name and file extension and located in the specified bundle subdirectory.
-
- pathForResource:ofType:inDirectory:forLocalization:
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.
-
- pathsForResourcesOfType:inDirectory:
Returns an array containing the pathnames for all bundle resources having the specified filename extension and residing in the resource subdirectory.
-
- pathsForResourcesOfType:inDirectory:forLocalization:
Returns an array containing the file for all bundle resources having the specified filename extension, residing in the specified resource subdirectory, and limited to global resources and those associated with the specified localization.
-
- preferredLocalizations
Returns an array of strings indicating the actual localizations contained in the receiver’s bundle.
-
- preflightAndReturnError:
Returns a Boolean value indicating whether the bundle’s executable code could be loaded successfully.
-
- principalClass
Returns the receiver’s principal class.
-
- privateFrameworksPath
Returns the full pathname of the receiver's subdirectory containing private frameworks.
-
- privateFrameworksURL
Returns the file URL of the receiver's subdirectory containing private frameworks.
-
- resourcePath
Returns the full pathname of the receiving bundle’s subdirectory containing resources.
-
- resourceURL
Returns the file URL of the receiver's subdirectory containing resource files.
-
- sharedFrameworksPath
Returns the full pathname of the receiver's subdirectory containing shared frameworks.
-
- sharedFrameworksURL
Returns the file URL of the receiver's subdirectory containing shared frameworks.
-
- sharedSupportPath
Returns the full pathname of the receiver's subdirectory containing shared support files.
-
- sharedSupportURL
Returns the file URL of the receiver's subdirectory containing shared support files.
-
- unload
Unloads the code associated with the receiver.
-
- URLForAuxiliaryExecutable:
Returns the file URL of the executable with the specified name in the receiver’s bundle.
-
- URLForResource:withExtension:
Returns the file URL for the resource identified by the specified name and file extension.
-
- URLForResource:withExtension:subdirectory:
Returns the file URL for the resource file identified by the specified name and extension and residing in a given bundle directory.
-
- URLForResource:withExtension:subdirectory:localization:
Returns the file URL 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.
-
- URLsForResourcesWithExtension:subdirectory:
Returns the file URL for the resource identified by the specified name and file extension and located in the specified bundle subdirectory.
-
- URLsForResourcesWithExtension:subdirectory:localization:
Returns an array containing the file URLs for all bundle resources having the specified filename extension, residing in the specified resource subdirectory, and limited to global resources and those associated with the specified localization.
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Class Method Details
+ (Array) allBundles
Returns an array of all the application’s non-framework bundles. The returned array includes the main bundle and all bundles that have been dynamically created but doesn’t contain any bundles that represent frameworks.
+ (Array) allFrameworks
Returns an array of all of the application’s bundles that represent frameworks. The returned array includes frameworks that are linked into an application when the application is built and bundles for frameworks that have been dynamically created.
+ (NSBundle) bundleForClass(aClass)
Returns the NSBundle object with which the specified class is associated.
+ (NSBundle) bundleWithIdentifier(identifier)
Returns the previously created NSBundle instance that has the specified bundle identifier. This method is typically used by frameworks and plug-ins to locate their own bundle at runtime. This method may be somewhat more efficient than trying to locate the bundle using the bundleForClass: method. However, if the initial lookup of an already loaded and cached bundle with the specified identifier fails, this method uses potentially time-consuming heuristics to attempt to locate the bundle.
+ (NSBundle) bundleWithPath(fullPath)
+ (NSBundle) bundleWithURL(url)
+ (NSBundle) mainBundle
Returns the NSBundle object that corresponds to the directory where the current application executable is located. This method allocates and initializes a bundle object if one doesn’t already exist. The new object corresponds to the directory where the application executable is located. Be sure to check the return value to make sure you have a valid bundle. This method may return a valid bundle object even for unbundled applications. In general, the main bundle corresponds to an application file package or application wrapper: a directory that bears the name of the application and is marked by a “.app” extension.
+ (String) pathForResource(name, ofType:extension, inDirectory:bundlePath)
Returns the full pathname for the resource file identified by the specified name and extension and residing in a given bundle directory. The method first looks for a matching resource file in the non-localized resource directory of the specified bundle. (In OS X, this directory is typically called Resources but in iOS, 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 Internationalization Programming Topics.Note: This method is best suited only for the occasional retrieval of resource files. In most cases where you need to retrieve bundle resources, it is preferable to use the NSBundle instance methods instead.
+ (Array) pathsForResourcesOfType(extension, inDirectory:bundlePath)
Returns an array containing the pathnames for all bundle resources having the specified extension and residing in the bundle directory at the specified path. This method provides a means for dynamically discovering multiple bundle resources of the same type. The method first looks for matching resource files in the nonlocalized resource directory of the specified bundle. (In OS X, this directory is typically called Resources but in iOS, it is the main bundle directory.) It then looks in the top level of any available language-specific “.lproj” directories. It does not recurse through other subdirectories at any of these locations. For more details see Internationalization Programming Topics.Note: This method is best suited only for the occasional retrieval of resource files. In most cases where you need to retrieve bundle resources, it is preferable to use the NSBundle instance methods instead.
+ (Array) preferredLocalizationsFromArray(localizationsArray)
Returns one or more localizations from the specified list that a bundle object would use to locate resources for the current user. This method does not return all localizations in preference order but only those from which NSBundle would get localized content, typically either a single non-region-specific localization or a region-specific localization followed by a corresponding non-region-specific localization as a fallback.However, clients who want all localizations in preference order can make repeated calls, each time taking the top localizations out of the list of localizations passed in.
+ (Array) preferredLocalizationsFromArray(localizationsArray, forPreferences:preferencesArray)
Returns the localizations that a bundle object would prefer, given the specified bundle and user preference localizations. This method does not return all localizations in preference order but only those from which NSBundle would get localized content, typically either a single non-region-specific localization or a region-specific localization followed by a corresponding non-region-specific localization as a fallback.However, clients who want all localizations in preference order can make repeated calls, each time taking the top localizations out of the list of localizations passed in.
+ (NSURL) URLForResource(name, withExtension:ext, subdirectory:subpath, inBundleWithURL:bundleURL)
Creates and returns a file URL for the resource with the specified name and extension in the specified bundle.
+ (Array) URLsForResourcesWithExtension(ext, subdirectory:subpath, inBundleWithURL:bundleURL)
Returns an array containing the file URLs for all bundle resources having the specified filename extension, residing in the specified resource subdirectory, within the specified bundle.
Instance Method Details
- (String) builtInPlugInsPath
Returns the full pathname of the receiver's subdirectory containing plug-ins. 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.
- (NSURL) builtInPlugInsURL
Returns the file URL of the receiver's subdirectory containing plug-ins. This method returns the appropriate path for modern application and framework bundles. This method may not return a URL for non-standard bundle formats or for some older bundle formats.
- (String) bundleIdentifier
Returns the receiver’s bundle identifier.
- (String) bundlePath
Returns the full pathname of the receiver’s bundle directory.
- (NSURL) bundleURL
Returns the full URL of the receiver’s bundle directory.
- (Class) classNamed(className)
Returns the Class object for the specified name. If the bundle’s executable code is not yet loaded, this method dynamically loads it into memory. Classes (and categories) are loaded from just one file within the bundle directory; this code file has the same name as the directory, but without the extension (“.bundle”, “.app”, “.framework”). As a side effect of code loading, the receiver posts NSBundleDidLoadNotification after all classes and categories have been loaded; see “Notifications” for details.
- (String) developmentLocalization
Returns the localization used to create the bundle. The returned localization corresponds to the value in the CFBundleDevelopmentRegion key of the bundle’s property list (Info.plist).
- (Array) executableArchitectures
Returns an array of numbers indicating the architecture types supported by the bundle’s executable. 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.”
- (String) executablePath
Returns the full pathname of the receiver's executable file.
- (NSURL) executableURL
Returns the file URL of the receiver's executable file.
- (Hash) infoDictionary
Returns a dictionary that contains information about the receiver. Common keys for accessing the values of the dictionary are CFBundleIdentifier, NSMainNibFile, and NSPrincipalClass.
- (Object) initWithPath(fullPath)
Returns an NSBundle object initialized to correspond to the specified directory. It’s not necessary to allocate and initialize an instance for the main bundle; use the mainBundle class method to get this instance. You can also use the bundleWithPath: class method to obtain a bundle identified by its directory path.
- (Object) initWithURL(url)
Returns an NSBundle object initialized to correspond to the specified file URL. It’s not necessary to allocate and initialize an instance for the main bundle; use the mainBundle class method to get this instance. You can also use the bundleWithURL: class method to obtain a bundle identified by its file URL.
- (Boolean) isLoaded
Obtains information about the load status of a bundle.
- (Boolean) load
Dynamically loads the bundle’s executable code into a running program, if the code has not already been loaded. You can use this method to load the code associated with a dynamically loaded bundle, such as a plug-in or framework. Prior to 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 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.
- (Boolean) loadAndReturnError(error)
Loads the bundle’s executable code and returns any errors. If this method returns NO and you pass a value for the error parameter, a suitable error object is returned in that parameter. Potential errors returned are in the Cocoa error domain and include the types that follow. For a full list of error types, see FoundationErrors.h. NSFileNoSuchFileError - returned if the bundle’s executable file was not located.NSExecutableNotLoadableError - returned if the bundle’s executable file exists but could not be loaded. This error is returned if the executable is not recognized as a loadable executable. It can also be returned if the executable is a PEF/CFM executable but the current process does not support that type of executable. NSExecutableArchitectureMismatchError - returned if the bundle executable does not include code that matches the processor architecture of the current processor. NSExecutableRuntimeMismatchError - returned if the bundle’s required Objective-C runtime information is not compatible with the runtime of the current process.NSExecutableLoadError - returned if the bundle’s executable failed to load for some detectable reason prior to linking. This error might occur if the bundle depends on a framework or library that is missing or if the required framework or library is not compatible with the current architecture or runtime version.NSExecutableLinkError - returned if the executable failed to load due to link errors but is otherwise alright.The error object may contain additional debugging information in its description that you can use to identify the cause of the error. (This debugging information should not be displayed to the user.) You can obtain the debugging information by invoking the error object’s description method in your code or by using the print-object command on the error object in gdb.
- (Array) localizations
Returns a list of all the localizations contained within the receiver’s bundle.
- (Hash) localizedInfoDictionary
Returns a dictionary with the keys from the bundle’s localized property list. 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.
- (String) localizedStringForKey(key, value:value, table:tableName)
Returns a localized version of the string designated by the specified key and residing in the specified table. For more details about string localization and the specification of a .strings file, see ““String Resources”.”Using the user default NSShowNonLocalizedStrings, you can alter the behavior of localizedStringForKey:value:table: to log a message when the method can’t find a localized string. If you set this default to YES (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:
- (Object) objectForInfoDictionaryKey(key)
Returns the value associated with the specified key in the receiver's information property list. Use of this method is preferred over other access methods because it returns the localized value of a key when one is available.
- (String) pathForAuxiliaryExecutable(executableName)
Returns the full pathname of the executable with the specified name in the receiver’s bundle. 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.
- (String) pathForResource(name, ofType:extension)
Returns the full pathname for the resource identified by the specified name and file extension. The method first looks for a matching resource file in the non-localized resource directory of the specified bundle. (In OS X, this directory is typically called Resources but in iOS, 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 Internationalization Programming Topics.The following code fragment gets the path to a plist within the bundle, and loads it into an NSDictionary.
- (String) pathForResource(name, ofType:extension, inDirectory:subpath)
Returns the full pathname for the resource identified by the specified name and file extension and located in the specified bundle subdirectory. If subpath is nil, this method searches the top-level nonlocalized resource directory and the top-level of any language-specific directories. (In OS X, the top-level nonlocalized resource directory is typically called Resources but in iOS, it is the main bundle directory.) For example, suppose you have a Mac app 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. Whether this method recurses through subdirectories is dependent on the extension parameter. If nil or an empty string it will recurse, otherwise, it does not. (The search order for the language-specific directories corresponds to the user’s preferences.) For more details see Internationalization Programming Topics.
- (String) pathForResource(name, ofType:extension, inDirectory:subpath, forLocalization:localizationName)
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. This method is equivalent to pathForResource:ofType:inDirectory:, 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 preferredLocalizationsFromArray:forPreferences: for how to determine what localizations are available.
- (Array) pathsForResourcesOfType(extension, inDirectory:subpath)
Returns an array containing the pathnames for all bundle resources having the specified filename extension and residing in the resource subdirectory. This method provides a means for dynamically discovering multiple bundle resources of the same type. If extension is an empty string or nil, all bundle resources in the specified resource directory are returned. The argument subpath specifies the name of a specific subdirectory to search within the current bundle’s resource directory hierarchy. If subpath is nil, this method searches the top-level nonlocalized resource directory and the top-level of any language-specific directories. (In OS X, the top-level nonlocalized resource directory is typically called Resources but in iOS, it is the main bundle directory.) For example, suppose you have a Mac app 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 Internationalization Programming Topics.
- (Array) pathsForResourcesOfType(extension, inDirectory:subpath, forLocalization:localizationName)
Returns an array containing the file for all bundle resources having the specified filename extension, residing in the specified resource subdirectory, and limited to global resources and those associated with the specified localization. This method is equivalent to pathsForResourcesOfType:inDirectory:, except that only nonlocalized resources and those in the language-specific .lproj directory specified by localizationName are searched.
- (Array) preferredLocalizations
Returns an array of strings indicating the actual localizations contained in the receiver’s bundle.
- (Boolean) preflightAndReturnError(error)
Returns a Boolean value indicating whether the bundle’s executable code could be loaded successfully. This method does not actually load the bundle’s executable code. Instead, it performs several checks to see if the code could be loaded and with one exception returns the same errors that would occur during an actual load operation. The one exception is the NSExecutableLinkError error, which requires the actual loading of the code to verify link errors. For a list of possible load errors, see the discussion for the loadAndReturnError: method.
- (Class) principalClass
Returns the receiver’s principal class. The principal class typically controls all the other classes in the bundle; it should mediate between those classes and classes external to the bundle. Classes (and categories) are loaded from just one file within the bundle directory. NSBundle obtains the name of the code file to load from the dictionary returned from infoDictionary, using “NSExecutable” as the key. The bundle determines its principal class in one of two ways:It first looks in its own information dictionary, which extracts the information encoded in the bundle’s property list (Info.plist). NSBundle obtains the principal class from the dictionary using the key NSPrincipalClass. For non-loadable bundles (applications and frameworks), if the principal class is not specified in the property list, the method returns nil. If the principal class is not specified in the information dictionary, NSBundle identifies the first class loaded as the principal class. When several classes are linked into a dynamically loadable file, the default principal class is the first one listed on the ld command line. In the following example, Reporter would be the principal class:The order of classes in Xcode’s project browser is the order in which they will be linked. To designate the principal class, control-drag the file containing its implementation to the top of the list.As a side effect of code loading, the receiver posts NSBundleDidLoadNotification after all classes and categories have been loaded; see “Notifications” for details. The following method obtains a bundle by specifying its path (bundleWithPath:), then loads the bundle with principalClass and uses the returned class object to allocate and initialize an instance of that class:
- (String) privateFrameworksPath
Returns the full pathname of the receiver's subdirectory containing private 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.
- (NSURL) privateFrameworksURL
Returns the file URL of the receiver's subdirectory containing private frameworks. This method returns the appropriate path for modern application and framework bundles. This method may not return a URL for non-standard bundle formats or for some older bundle formats.
- (String) resourcePath
Returns the full pathname of the receiving bundle’s subdirectory containing resources.
- (NSURL) resourceURL
Returns the file URL of the receiver's subdirectory containing resource 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.
- (String) sharedFrameworksPath
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.
- (NSURL) sharedFrameworksURL
Returns the file URL 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 URL for non-standard bundle formats or for some older bundle formats.
- (String) sharedSupportPath
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.
- (NSURL) sharedSupportURL
Returns the file URL 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.
- (Boolean) unload
Unloads the code associated with the receiver. 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.
- (NSURL) URLForAuxiliaryExecutable(executableName)
Returns the file URL of the executable with the specified name in the receiver’s bundle. This method returns the appropriate path for modern application and framework bundles. This method may not return a URL for non-standard bundle formats or for some older bundle formats.
- (NSURL) URLForResource(name, withExtension:extension)
Returns the file URL for the resource identified by the specified name and file extension. If extension is an empty string or nil, the returned pathname is the first one encountered where the file name exactly matches name. The method first looks for a matching resource file in the nonlocalized resource directory of the specified bundle. (In OS X, this directory is typically called Resources but in iOS, 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 Internationalization Programming Topics.
- (NSURL) URLForResource(name, withExtension:extension, subdirectory:subpath)
Returns the file URL for the resource file identified by the specified name and extension and residing in a given bundle directory. The method first looks for a matching resource file in the non-localized resource directory of the specified bundle. (In OS X, this directory is typically called Resources but in iOS, 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 Internationalization Programming Topics.
- (NSURL) URLForResource(name, withExtension:extension, subdirectory:subpath, localization:localizationName)
Returns the file URL 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. This method is equivalent to URLsForResourcesWithExtension:subdirectory:, 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 preferredLocalizationsFromArray:forPreferences: for how to determine what localizations are available.
- (Array) URLsForResourcesWithExtension(extension, subdirectory:subpath)
Returns the file URL for the resource identified by the specified name and file extension and located in the specified bundle subdirectory. If subpath is nil, this method searches the top-level non-localized resource directory and the top-level of any language-specific directories. (In OS X, the top-level non-localized resource directory is typically called Resources but in iOS, it is the main bundle directory.) For example, suppose you have a Mac app 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 Internationalization Programming Topics.
- (Array) URLsForResourcesWithExtension(extensions, subdirectory:subpath, localization:localizationName)
Returns an array containing the file URLs for all bundle resources having the specified filename extension, residing in the specified resource subdirectory, and limited to global resources and those associated with the specified localization. This method is equivalent to URLsForResourcesWithExtension:subdirectory:, except that only nonlocalized resources and those in the language-specific .lproj directory specified by localizationName are searched.