What is a Plist File?

Document icon image for the plist file type.

The Property List (plist) file is a data format used to store configuration settings and other types of structured data in macOS, iOS, and other Apple operating systems. The history of the plist file can be traced back to the NeXTSTEP operating system, which was developed by NeXT Computer, Inc. in the late 1980s.

The NeXTSTEP operating system used a file format called NeXT Property List, which was similar in structure to the current plist format. NeXT Property List was used to store system preferences and other configuration data in a hierarchical format. When Apple acquired NeXT Computer in 1997, they inherited the NeXTSTEP operating system and its associated file formats.

In 2001, Apple released Mac OS X, which was based on the NeXTSTEP operating system. The plist file format was included in Mac OS X. Plist files are stored in either XML or binary format. Each format has its own advantages. While the XML version of a plist can be edited using a simple text editor, the binary format is more efficient for storing large amounts of data.

Today, plist files are used extensively throughout Apple’s operating systems to store a wide range of configuration data, from system preferences to application settings. They are also used by developers to store application-specific preferences and other data.

Are you a developer looking to improve your productivity with plists?

Plist Converter is an app for macOS that can batch convert plist files to and from the XML and Binary formats. Plist Converter can also convert property list files to Swift and Objective-C source code. Learn more about the Plist Converter app here.

How to Disable NSScrollView Scrolling

Unlike UIScrollView on iOS, NSScrollView on Mac does not have a handy scrollEnabled property for you to set to NO if you need to temporarily disable scrolling in your app.

If you Google around, you can find several posts on websites like stackoverflow that ask questions like How can I disable the vertical scrolling of a NSScrollView? Some have suggested setting the hasVerticalScroller property to NO as the answer. However, the hasVerticalScroller property only effects the visibility of the scroller, a value of NO does not actually prevent scrolling.

There are also ways to constrain scrolling from an NSView subclass, as described in Apple’s documentation here. Constraining scrolling from a view subclass can be useful, but what if you want to just temporarily disable scrolling?

The easiest way to disable scrolling it seems is to subclass NSScrollView and add a BOOL property with a name like scrollingEnabled. Then you can simply override the designated initializers (initWithFrame: and initWithCoder:) and set the ivar of the property to YES as the default value:

-(instancetype)initWithFrame:(NSRect)frameRect 
{ 
   self = [super initWithFrame:frameRect]; 
   if (self) 
   { 
       [self setUpOnInit]; 
   } 
   return self; 
}
 
- (instancetype)initWithCoder:(NSCoder *)coder 
{ 
    self = [super initWithCoder:coder]; 
    if (self) 
    { 
         [self setUpOnInit]; 
    } 
    return self; 
}
 
-(void)setUpOnInit
{
   //Set all default values. 
   _scrollingEnabled = YES; 
}

Now you can just override the scrollWheel: method and check the property:

-(void)scrollWheel:(NSEvent *)theEvent 
{ 
    if (self.scrollingEnabled) {  
      [super scrollWheel:theEvent];  
     } 
    else {  
       //scrolling is disabled. 
    } 
}

This technique will work in most cases, but there may be times when a view inside of a scroll view implements autoscrolling behavior (perhaps if the view is a dragging destination). If you need to temporarily disable scrolling in such a case, you should also subclass NSClipView and block scrolling by overriding the -constrainBoundsRect: method like this:

-(NSRect)constrainBoundsRect:(NSRect)proposedBounds
{
    MyScrollViewSubclass *mainScrollView = (MyScrollViewSubclass*)self.superview;
 
    if (mainScrollView.scrollingEnabled)
    {
        return [super constrainBoundsRect:proposedBounds];
    }
    else
    {
        //Disabled
        return self.documentVisibleRect;
    }
}

How to Deprecate your Own API in Objective-C

To mark some of your own API as deprecated in Objective-C, you simply can add the following attribute to your method declaration (as seen in the snippet below):

-(void)myOldMethod __attribute((deprecated("Use the myNewMethod instead.")));

Now when you call myOldMethod in your code, the compiler will warn you that: “myOldMethod is deprecated. Use the myNewMethod instead”. You can also add the deprecated attribute to property declarations.

But what if you wanted to be more specific? For instance, if there is a better way to handle something in the iOS 8 SDK, you can mark an old method as deprecated only for projects that have iOS 8.0 or later as the deployment target.

-(void)myOldMethod NS_DEPRECATED_IOS(3_0, 8_0,"Use myNewMethod instead.");

Using the code snippet above, if you call myOldMethod the compiler will only warn you that the method is deprecated if your project’s deployment target is set to iOS 8 or later.

Deprecating your own methods can come in handy especially if you have written your own framework that is used across multiple projects. You may choose to deprecate some of your own API rather than removing the methods entirely until you get around to modifying your existing projects to use your new API.

iOS Devices: Screen Bounds List

Dimensions (in points):

*Note: Starting in iOS 8, the bounds property on UIScreen is orientation based, so for example if the bounds in portrait mode is 320×480, in the landscape orientation the bounds would be 480×320. The list below assumes that the device is in the portrait orientation.

320 x 480
-iPhone 4s and earlier models.
320 x 568
-iPhone 5
-iPhone 5S
-iPhone 5C
375 x 667
-iPhone 6
414 x 736
-iPhone 6 Plus
768 x 1024
-iPad