---
title: "AssetLibrary"
description: "AssetLibrary"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/ios/reference/assetlibrary"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-09-21"
---

# AssetLibrary

## AssetLibrary

AssetLibrary class to fetch details of files on Contentstack server.

## setHeader:forKey:

Set a header for AssetLibrary

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
AssetLibrary * asset = [stack assetLibrary];
[asset setHeader:@"MyValue" forKey:@"My-Custom-Header"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let asset = stack.assetLibrary()
asset.setHeader("MyValue", forKey: "My-Custom-Header")
```

The header value

The header key

## addHeadersWithDictionary:

Set a header for AssetLibrary

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
AssetLibrary * asset = [stack assetLibrary];
[asset addHeadersWithDictionary:@{@"My-Custom-Header": @"MyValue"}];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let asset = stack.assetLibrary()
asset.addHeadersWithDictionary(["My-Custom-Header":"MyValue"])
```

The headers as dictionary which needs to be added to the application.

## removeHeaderForKey:

Removes a header from this AssetLibrary

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
AssetLibrary * asset = [stack assetLibrary];
[asset removeHeaderForKey:@"key"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let asset = stack.assetLibrary()
asset.removeHeaderForKey("key")
```

The header key that needs to be removed.

## sortWithKey:orderBy:

Sorts the assets in the given order on the basis of the specified field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
AssetLibrary* asset = [stack assetLibrary];
[asset sortWithKey:@"updated_at" orderBy:Ascending];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var asset:AssetLibrary = stack.assetLibrary()
asset.sortWithKey("updated_at" orderBy:Ascending)
```

field uid based on which the ordering should be done.

ascending or descending order in which results should come.

## objectsCount

Provides only the number of assets.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];

AssetLibrary * asset = [stack assetLibrary];
[asset objectsCount];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let asset = stack.assetLibrary()
asset.objectsCount()
```

## includeCount

This method also includes the total number of assets returned in the response.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];

AssetLibrary * asset = [stack assetLibrary];
[asset includeCount];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let asset = stack.assetLibrary()
asset.includeCount()
```

## includeRelativeUrls

This method includes the relative url of assets.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];

AssetLibrary * asset = [stack assetLibrary];
[asset includeRelativeUrls];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let asset = stack.assetLibrary()
asset.includeRelativeUrls()
```

## includeFallback

Retrieve the published content of the fallback locale entry if the entry is not localized in specified locale.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];

AssetLibrary * asset = [stack assetLibrary];
[asset includeFallback];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let asset = stack.assetLibrary()
asset.includeFallback()
```

## includeBranch

Retrieve the branch for the published content.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];

AssetLibrary * asset = [stack assetLibrary];
[asset includeBranch];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let asset = stack.assetLibrary()
asset.includeBranch()
```

## locale:

This method provides all the assets for the specified language in the response.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];

AssetLibrary * asset = [stack assetLibrary];
[asset locale:@"en-us"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let asset = stack.assetLibrary()
asset.locale("en-us")
```

Language enum for all language available.

## fetchAll:

This method provides all the assets.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];

AssetLibrary * asset = [stack assetLibrary];
[asset fetchAll:^(ResponseType type, NSArray *result, NSError *error) {

}];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let asset = stack.assetLibrary()
asset.fetchAll { (responseType, result!, error!) -> Void in

})
```

Block to be called once operation is done.

## where:

The where() method retrieves the assets from the stack using any other field UID of the assets.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
AssetLibrary * asset = [stack assetLibrary];
[asset where:@"fieldName"equalTo:@"Value"];
[asset fetchAll:^(ResponseType type, NSArray *result, NSError *error) {
if (error) { 
   NSLog(@"Error: %@", error.localizedDescription); 
} else {
   NSLog(@"Fetched assets: %@", result); }
}];

Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let asset = stack.assetLibrary()
asset.where("fieldName",equalTo:"Value")
asset.fetchAll { (responseType, result, error) in
if let error = error {
     print("Error: \(error.localizedDescription)") 
  } else { 
     print("Fetched assets: \(result)") 
  } 
}
```

Field UID of the Asset

The value to match for the field.

property to assign cache policy like CACHE\_THEN\_NETWORK, NETWORK\_ELSE\_CACHE, NETWORK\_ONLY, etc.

## AssetLibrary | iOS Delivery SDK | Contentstack

AssetLibrary fetches details of files stored on the Contentstack server through the iOS Delivery SDK, retrieving collections of assets.