Nib File Format Descriptions

/ Comments off

Learn here what the.NIB file is, and what program you need to open or convert the.NIB file. Specifications for the.NIB file format and downloadable sample. Mar 20, 2016 Nib files play an important role in the creation of applications in OS X and iOS. With nib files, you create and manipulate your user interfaces.

  1. File Format Download

Accessing Files and Directories Before you can open a file, you first have to locate it in the file system. The system frameworks provide many routines for obtaining references to many well-known directories, such as the Library directory and its contents.

You can also specify locations manually by building a URL or string-based path from known directory names. When you know the location of a file, you can then start planning the best way to access it. Depending on the type of file, you may have several options. For known file types, you typically use built-in system routines to read or write the file contents and give you an object that you can use. For custom file types, you may need to read the raw file data yourself. Choose the Right Way to Access Files Although you can open any file and read its contents as a stream of bytes, doing so is not always the right choice. MacOS and iOS provide built-in support that makes opening many types of standard file formats (such as text files, images, sounds, and property lists) much easier.

For these standard file formats, use the higher-level options for reading and writing the file contents. Table 2-1 lists the common file types supported by the system along with information about how you access them. Table 2-1 File types with specialized routines File Type Examples Description Resource files Nib files Image files Sound files Strings files Localized resources Apps use resource files to store data that is independent of the code that uses it. Resource files are commonly used to store localizable content such as strings and images. The process for reading data from a resource file depends on the resource type. For information about how to read the contents of resource files, see. Text files Plain text file UTF-8 formatted file UTF-16 formatted file A text file is an unstructured sequence of ASCII or Unicode characters.

You typically load the contents of a text file into an object but may also read and write a text file as a raw stream of characters. For information about using the NSString class to load text from a file, see. Structured data files XML file Property list file Preference file A structured data file usually consists of string-based data arranged using a set of special characters.

For information about parsing XML, see. Archive files Binary files created using a keyed archiver object An archive is a file format used to store a persistent version of your app’s runtime objects.

An archiver object encodes the state of the objects into a stream of bytes that can be written to disk all at once. An unarchiver reverses the process, using the stream of bytes to re-create the objects and restore them to their previous state. Archives are often a convenient alternative to implementing custom binary file formats for your documents or other data files. For information on how to create and read archive files, see. File packages Custom document formats A file package is a directory that contains any number of custom data files but which is presented to the user as if it were a single file.

Apps can use file packages to implement complex file formats that contain multiple distinct files, or a mixture of different types of files. For example, you might use a file package if your file format includes both a binary data file and one or more image, video, or audio files. You access the contents of a file package using objects, as described in. Bundles Apps Plug-ins Frameworks Bundles provide a structured environment for storing code and the resources used by that code. Most of the time, you do not work with the bundle itself but with its contents. However, you can locate bundles and obtain information about them as needed.

For information about bundles and how you access them, see Code files Binary code resources Dynamic shared libraries Apps that work with plug-ins and shared libraries need to be able to load the associated code for that item to take advantage of its functionality. For information about how to load code resources into memory, see. In situations where the standard file formats are insufficient, you can always create your own custom file formats. When reading and writing the content of custom files, you read and write data as a stream of bytes and apply those bytes to your app’s file-related data structures. You have complete control over how you read and write the bytes and how you manage your file-related data structures. For more information about the techniques for reading and writing files that use custom file formats, see. Specifying the Path to a File or Directory The preferred way to specify the location of a file or directory is to use the class.

Although the class has many methods related to path creation, URLs offer a more robust way to locate files and directories. For apps that also work with network resources, URLs also mean that you can use one type of object to manage items located on a local file system or on a network server. Note: In addition to NSURL, you can also use the opaque type to manipulate paths as URLs. The NSURL class is toll-free bridged with the CFURLRef type, which means you can use them interchangeably in your code. For more information about how to create and manipulate URLs using Core Foundation, see. For most URLs, you build the URL by concatenating directory and file names together using the appropriate NSURL methods until you have the path to the item.

A URL built in that way is referred to as a path-based URL because it stores the names needed to traverse the directory hierarchy to locate the item. (You also build string-based paths by concatenating directory and file-names together, with the results stored in a slightly different format than that used by the NSURL class.) In addition to path-based URLs, you can also create a file reference URL, which identifies the location of the file or directory using a unique ID. All of the following entries are valid references to a file called MyFile.txt in a user’s Documents directory: Path-based URL: file://localhost/Users/steve/Documents/MyFile.txt File reference URL: file:///.file/id=65272/ String-based path: /Users/steve/Documents/MyFile.txt You create URL objects using the NSURL methods and convert them to file reference URLs only when needed. Path-based URLs are easier to manipulate, easier to debug, and are generally preferred by classes such as. An advantage of file reference URLs is that they are less fragile than path-based URLs while your app is running.

If the user moves a file in the Finder, any path-based URLs that refer to the file immediately become invalid and must be updated to the new path. However, as long as the file moved to another location on the same disk, its unique ID does not change and any file reference URLs remain valid.

Important: Although they are safe to use while your app is running, file reference URLs are not safe to store and reuse between launches of your app because a file’s ID may change if the system is rebooted. If you want to store the location of a file persistently between launches of your app, create a bookmark as described in Locating Files Using Bookmarks. Of course, there are still times when you might need to use strings to refer to a file. Fortunately, the NSURL class provides methods to convert path-based URLs to and from NSString objects. You might use a string-based path when presenting that path to the user or when calling a system routine that accepts strings instead of URLs. The conversion between NSURL objects and NSString objects is done using the NSURL class’s method. Because NSURL and NSString describe only the location of a file or directory, you can create them before the actual file or directory exists.

Neither class attempts to validate the actual existence of the file or directory you specify. In fact, you must create the path to a nonexistent file or directory before you can create it on disk. If you have an NSURL object that refers to an actual file or directory on disk, and you want to get the user visible name of the volume on which it resides, you use the method in a two step process:. Use the constant to obtain the volume URL from the resource URL. Use the constant to obtain the user visible volume name from the volume URL.

Use the NSURLLocalizedNameKey constant rather than the constant. Using NSURLNameKey returns the name of the volume in the file system, which may not be the same as the user visible name. Listing 2-1 demonstrates this process for the current user’s home directory.

Listing 2-1 Obtaining the user visible volume name for a resource URL. NSURL.

url = NSBundle mainBundle URLForResource:@'MyImage' withExtension:@'png'; For more information about bundles, including how to locate items in a bundle, see. For specific information about loading and using resources in your app, see. Locating Items in the Standard Directories When you need to locate a file in one of the standard directories, use the system frameworks to locate the directory first and then use the resulting URL to build a path to the file.

File Format Download

The Foundation framework includes several options for locating the standard system directories. By using these methods, the paths will be correct whether your app is sandboxed or not:.

File layout

The method of the NSFileManager class returns a directory’s location packaged in an NSURL object. The directory to search for is an constant. These constants provide URLs for the user’s home directory, as well as most of the standard directories. The function behaves like the URLsForDirectory:inDomains: method but returns the directory’s location as a string-based path. Use the method instead.

The function returns the path to either the user’s or app’s home directory. (Which home directory is returned depends on the platform and whether the app is in a sandbox.) When an app is sandboxed the home directory points to the app’s sandbox, otherwise it points to the User’s home directory on the file system. If constructing a file to a subdirectory of a user’s home directory, consider using the method instead.

You can use the URL or path-based string you receive from the preceding routines to build new objects with the locations of the files you want. Both the and classes provide path-related methods for adding and removing path components and making changes to the path in general. Listing 2-2 shows an example that searches for the standard Application Support directory and creates a new URL for a directory containing the app’s data files. Listing 2-2 Creating a URL for an item in the app support directory.

Note: Apps rarely share the files stored in the Application Support, Caches or Temp directories. Therefore, you don’t typically need to use a file coordinator ( NSFileCoordinator) when reading or writing to these locations. For more information about file coordination, see.

Tips for Accessing Files and Directories Because the file system is a resource shared by all processes, including system processes, use it carefully. Even on systems with solid-state disk drives, file operations tend to be a little slower because of the latency involved in retrieving data from the disk. And when you do access files, it is important that you do so in a way that is secure and does not interfere with other processes. Perform File Operations Lazily Operations involving the file system should be performed only when they are absolutely necessary. Accessing the file system usually takes a lot of time relative to other computer-wide tasks. So make sure you really need to access the disk before you do. Specifically:.

Write data to disk only when you have something valuable to save. The definition of what is valuable is different for each app but should generally involve information that the user provides explicitly. For example, if your app creates some default data structures at launch time, do not save those structures to disk unless the user changes them. Read data from disk only when you need it. In other words, load data that you need for your user interface now but do not load an entire file just to get one small piece of data from that file. For custom file formats, use file mapping or read only the few chunks of a file that you need to present your user interface. Read any remaining chunks as needed in response to user interactions with the data.

For structured data formats, use Core Data to manage and optimize the reading of data for you. Use Secure Coding Practices There are several principles you can follow to help ensure that you do not have file-based security vulnerabilities in your program:. Check the result codes for any functions or methods you call. Result codes are there to let you know that there is a problem, so do pay attention to them. For example, if you try to delete a directory that you think is empty and get an error code, you might find that the directory is not empty after all. When working in a directory to which your process does not have exclusive access, you must check to make sure a file does not exist before you create it. You must also verify that the file you intend to read from or write to is the same file you created.

Whenever possible use routines that operate on file descriptors rather than pathnames. In this way you can be sure you’re always dealing with the same file. Intentionally create files as a separate step from opening them so that you can verify that you are opening a file you created rather than one that already existed.

Know whether the function you are calling follows symbolic links. For example, the lstat function gives you the status of a file regardless of whether it’s a normal file or a symbolic link, but the stat function follows symbolic links and, if the specified file was a symbolic link, returns the status of the linked-to file. Therefore, if you use the stat function, you might be accessing a different file than you expected. Before you read a file, make sure that file has the owner and permissions you expect. Be prepared to fail gracefully (rather than hanging) if it does not. Set your process’ file code creation mask (umask) to restrict access to files created by your process. The umask is a bitmask that alters the default permissions of a new file.

You do not reset the umask for your app, your process inherits the umask from its parent process. For more information about setting the umask, see the umask(2) man page. For additional tips and coding practices, see in. Assume Case Sensitivity for Paths When searching or comparing filenames, always assume that the underlying file system is case sensitive. MacOS supports many file systems that use case to differentiate between files. Even on file systems (such as HFS+) that support case insensitivity, there are still times when case may be used to compare filenames. For example, the class and CFBundle APIs consider case when searching directories for named resources.

Include Filename Extensions for New Files All files should have a filename extension that reflects the type of content contained in the file. Filename extensions help the system determine how to open files and also make it easier to exchange files with other computers or other platforms. For example, network transfer programs often use filename extensions to determine the best way to to transfer files between computers. Use Display Names When Presenting Items Whenever you need to present the name of a file or directory in your user interface, always use the item’s display name. Using the display name ensures that what your app presents matches what the Finder and other apps are presenting.

For example, if your app shows the path to a file, using the display name ensures that the path is localized in accordance with the current user’s language settings. For more information about display names, see. Accessing Files Safely from Background Threads In general, the objects and functions used to access and manipulate files can be used from any thread of your app.

However, as with all threaded programming, make sure you manipulate files safely from your background threads:. Avoid using the same file descriptor from multiple threads.

Doing so could cause each thread to disrupt the state of the other. Always use file coordinators to access files. File coordinators provide notifications when other threads in your program (or other processes) access the same file.

You can use these notifications to clean up your local data structures or perform other relevant tasks. Create a unique instance of for each thread when copying, moving, linking, or deleting files. Although most file manager operations are thread-safe, operations involving a delegate require a unique instance of NSFileManager, especially if you are performing those operations on background threads.

If you cannot open the NIB file on your computer - there may be several reasons. The first and most important reason (the most common) is the lack of a suitable application that supports NIB among those that are installed on your computer. A very simple way to solve this problem is to find and download the appropriate application.

The first part of the task has already been done – the software supporting the NIB file can be found below. Now just download and install the appropriate application. This site also defines other possible causes causing the problems with NIB files. Possible problems with the files that are in the NIB format The inability to open and operate the NIB file does not necessarily mean that you do not have an appropriate software installed on your computer.

There may be other problems that also block our ability to operate the Interface Builder User Interface Resources file. Below is a list of possible problems. Corruption of a NIB file which is being opened.

Incorrect links to the NIB file in registry entries. Accidental deletion of the description of the NIB from the Windows registry. Incomplete installation of an application that supports the NIB format. The NIB file which is being opened is infected with an undesirable malware. The computer does not have enough hardware resources to cope with the opening of the NIB file. Drivers of equipment used by the computer to open a NIB file are out of date.

If you are sure that all of these reasons do not exist in your case (or have already been eliminated), the NIB file should operate with your programs without any problem. If the problem with the NIB file has not been solved, it may be due to the fact that in this case there is also another rare problem with the NIB file. In this case, the only you can do is to ask for assistance of a professional staff.