AvailabilityAttribute Constructors

Definition

Overloads

AvailabilityAttribute()

Default constructor, sets not availability.

AvailabilityAttribute(Platform, Platform, Platform, Platform)

Defines the availability range of a particular API.

AvailabilityAttribute()

Default constructor, sets not availability.

public AvailabilityAttribute ();

Applies to

AvailabilityAttribute(Platform, Platform, Platform, Platform)

Defines the availability range of a particular API.

public AvailabilityAttribute (ObjCRuntime.Platform introduced, ObjCRuntime.Platform deprecated = ObjCRuntime.Platform.None, ObjCRuntime.Platform obsoleted = ObjCRuntime.Platform.None, ObjCRuntime.Platform unavailable = ObjCRuntime.Platform.None);
new ObjCRuntime.AvailabilityAttribute : ObjCRuntime.Platform * ObjCRuntime.Platform * ObjCRuntime.Platform * ObjCRuntime.Platform -> ObjCRuntime.AvailabilityAttribute

Parameters

introduced
Platform

The first version in which an API was introduced for a given platform.

deprecated
Platform

The first version in which the API was deprecated for a given platform; this means users should begin avoiding the API and migrating to a more suitable one, but it still technically works on the platform, but there is no guarantee for how long it will continue to work.

obsoleted
Platform

The first version in which the API was obsoleted (removed) from a given platform; this means the API no longer exists and cannot be used at all - a crash at runtime will occur if used on Xamarin. Native code referencing obsolete API will fail to compile (the attribute is enforced by Clang).

unavailable
Platform

The API has never existed in a given platform (e.g. available in iOS but not in macOS); this property is not versioned (can only be Platform.{None,Mac,iOS}) and applies to the entire lifetime (up to present) of a platform. "Unavailable" may be replaced in future versions by an "Introduced."

Remarks

The entire availability of an API can be expressed either with a single Availability attribute or with multiple attributes. It's entirely style. To demonstrate this, the Since, Lion, and MountainLion attributes are now actually subclasses of the Availability attribute. This is because we do not want to break API, but also often the more terse attributes are simply nicer to use.

In addition to the Platform AvailabilityAttribute types, there's also PlatformHelper which contains a number of useful utilities for working with the Platform enumeration.

// 
// The following examples are all equivalent
//
[Since (4,0), Lion, Availability (Deprecated = Platform.iOS_6_0 | Platform.Mac_10_8)]
...

[Availability (Introduced = Platform.iOS_4_0)]
...

[Availability (Introduced = Platform.Mac_10_7)]
...

[Availability (Deprecated = Platform.iOS_6_0 | Platform.Mac_10_8)]
...

[Availability (
    Introduced = Platform.iOS_4_0 | Platform.Mac_10_7,
    Deprecated = Platform.iOS_6_0 | Platform.Mac_10_8
)]  
...

Applies to