Framework

Foundation

Access essential data types, collections, and operating-system services to define the base layer of functionality for your app.

Overview

The Foundation framework provides a base layer of functionality for apps and frameworks, including data storage and persistence, text processing, date and time calculations, sorting and filtering, and networking. The classes, protocols, and data types defined by Foundation are used throughout the macOS, iOS, watchOS, and tvOS SDKs.

Topics

Fundamentals

Numbers, Data, and Basic Values

Work with primitive values and other fundamental types used throughout Cocoa.

Strings and Text

Create and process strings of Unicode characters, use regular expressions to find patterns, and perform natural language analysis of text.

Collections

Use arrays, dictionaries, sets, and specialized collections to store and iterate groups of objects or values.

Dates and Times

Compare dates and times, and perform calendar and time zone calculations.

Units and Measurement

Label numeric quantities with physical dimensions to allow locale-aware formatting and conversion between related units.

Data Formatting

Convert numbers, dates, measurements, and other values to and from locale-aware string representations.

Filters and Sorting

Use predicates, expressions, and sort descriptors to examine elements in collections and other services.

App Support

Task Management

Manage your app's work and its interaction with the user and the system.

Resources

Access assets and other data bundled with your app.

Notifications

Design patterns for broadcasting information and for subscribing to broadcasts.

App Extension Support

Manage the interaction between an app extension and its hosting app.

Errors and Exceptions

Respond to problem situations in your interactions with APIs, and fine-tune your app for better debugging.

Scripting Support

Allow users to control your app with AppleScript and other automation technologies, or run scripts from within your app.

Files and Data Persistence

File System

Create, read, write, and examine files and folders in the file system.

Archives and Serialization

Convert objects and values to and from property list, JSON, and other flat binary representations.

Preferences

Persistently store domain-scoped pieces of information used to configure your app.

Spotlight

Search for files and other items on the local device, and index your app's content for searching.

iCloud

Manage files and key-value data that are automatically synchronized among a user's iCloud devices.

Networking

URL Loading System

Interact with URLs and communicate with servers using standard Internet protocols.

Bonjour

Advertise services for easy discovery on local networks, or discover services advertised by others.

Low-Level Utilities

XPC

Manage secure interprocess communication.

Object Runtime

Get low-level support for basic Objective-C features, Cocoa design patterns, and Swift integration.

Processes and Threads

Manage your app's interaction with the host operating system and other processes, and implement low-level concurrency features.

Streams, Sockets, and Ports

Use low-level Unix features to manage input and output among files, processes, and the network.

Classes

class NSFileProviderService

A service that provides a custom communication channel between your app and a File Provider extension.

Reference

Foundation Data Types

This document describes the data types and constants found in the Foundation framework.