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

# Stack

## Stack

Initialize an instance of ‘Stack’

## contentTypeWithName:

Gets the new instance of ContentType object with specified name.

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

ContentType *contentTypeObj = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

var contentTypeObj:ContentType = stack.contentTypeWithName("CONTENT_TYPE_UID")
```

Uid of the contentType to perform action.

## setHeader:forKey:

Set a header for Stack.

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

[stack setHeader:@"MyValue" forKey:@"My-Custom-Header"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

stack.setHeader("MyValue", forKey: "My-Custom-Header")
```

The header value

The header key

## addHeadersWithDictionary:

Set a header for Stack

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

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

stack.addHeadersWithDictionary(["My-Custom-Header":"MyValue"])
```

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

## removeHeaderForKey:

Removes a header from this Stack.

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

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

stack.removeHeaderForKey("key")
```

The header key that needs to be removed.

## assetLibrary

Represents a Asset on ‘Stack’ which can be executed to get AssetLibrary object.

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

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

var asset:AssetLibrary = stack.assetLibrary()
```

## asset

Represents an Asset on ‘Stack’ which can be executed to get Asset object.

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

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

var asset:Asset = stack.asset()
```

## assetWithUID:

Gets the new instance of Asset object with specified UID.

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

[[stack sync:^(SyncStack * Nullable syncStack, NSError * Nullable error) 

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

stack.sync({ ( syncStack:SyncStack, error: NSError) in

})
```

Uid of the Asset object to fetch.

## imageTransformWithUrl:andParams:

Transforms provided image url based on transformation parameters.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithInt:100], @"width", [NSNumber numberWithInt:100], @"height", nil];
NSString *transformedUrl = [stack imageTransformWithUrl:imageURL andParams:params];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let params:[String : AnyObject?] = [
  "width":100 as AnyObject,
  "height":100 as AnyObject,
];
let transformedUrl:String = stack.imageTransformation(withUrl: imageURL, andParams: params);
```

Url on which transformations to be applied.

Transformation parameters.

## getContentTypes:completion:

Gets all the ContentTypes and its Schema definition.

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

[stack getContentTypes:params completion:^(NSArray * _Nullable contentTypes, NSError * _Nullable error) {

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

stack.getContentTypes(params, { (contentTypes, error) in

})
```

params is dictionary of additional parameter

completionBlock to be called once operation is done.

## sync:

The Initial Sync request performs a complete sync of your app data. It returns all the published entries and assets of the specified stack in response. The response also contains a sync token, which you need to store, since this token is used to get subsequent delta updates later.

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

[[stack sync:^(SyncStack * Nullable syncStack, NSError * Nullable error) 

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

stack.sync({ ( syncStack:SyncStack, error: NSError) in

})
```

completionBlock called synchronization is done.

## syncPaginationToken:completion:

If the result of the initial sync (or subsequent sync) contains more than 100 records, the response would be paginated. It provides pagination token in the response. However, you do not have to use the pagination token manually to get the next batch, the SDK does that automatically until the sync is complete. Pagination token can be used in case you want to fetch only selected batches. It is especially useful if the sync process is interrupted midway (due to network issues, etc.). In such cases, this token can be used to restart the sync process from where it was interrupted.

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

[stack syncPaginationToken:@"PAGINATION_TOKEN" contentTypeArray completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) 

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

stack.syncPaginationToken("PAGINATION_TOKEN", completion: { ( syncStack:SyncStack, error: NSError) in

})
```

Pagination token from where to perform sync

completionBlock called synchronization is done.

## syncToken:completion:

You can use the sync token (that you receive after initial sync) to get the updated content next time. The sync token fetches only the content that was added after your last sync, and the details of the content that was deleted or updated.

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

[[stack syncToken:@"SYNC_TOKEN" contentTypeArray completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) 

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

stack.syncToken("SYNC_TOKEN", completion: { ( syncStack:SyncStack, error: NSError) in

})
```

Sync token from where to perform sync

completionBlock called synchronization is done.

## syncOnly:completion:

Perform a synchronization operation on specified classes.

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

NSArray *contentTypeArray = @[@“product”, @“multifield”]; 
[[stack syncOnly: contentTypeArray completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) 

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

let contentTypeArray = [“product”, “multifield”]
stack.syncOnly(contentTypeArray, completion: { ( syncStack:SyncStack, error: NSError) in

})
```

ContentType uids of classes to be expected.

completionBlock called synchronization is done.

## syncFrom:completion:

Perform a synchronization operation on specified date.

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

NSDate *date = [NSDate date]; 
[[stack syncFrom:date completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) 

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

let date = Date.date() 
stack.syncFrom(date, completion: { ( syncStack:SyncStack, error: NSError) in

})
```

Date from where sync data is needed.

completionBlock called synchronization is done.

## syncOnly:from:completion:

Perform a synchronization operation on specified classes, and date.

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

NSArray *contentTypeArray = @[@“product”, @“multifield”]; 
[[stack syncOnly: contentTypeArray from:date completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) 

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

let contentTypeArray = [“product”, “multifield”]
stack.syncOnly(contentTypeArray, from: date, completion: { ( syncStack:SyncStack, error: NSError) in

})
```

ContentType uids of classes to be expected.

Date from where sync data is needed.

completionBlock called synchronization is done.

## syncPublishType:completion:

Perform a synchronization operation on specified publishType.

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

[[stack syncPublishType:ENTRY_PUBLISHED completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) 

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

stack.syncPublishType(ENTRY_PUBLISHED, completion: { ( syncStack:SyncStack, error: NSError) in

})
```

PublishType for which sync is needed.

completionBlock called synchronization is done.

## syncLocale:completion:

Perform a synchronization operation on specified locale.

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

[[stack syncLocale:ENGLISH_UNITED_STATES completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) 

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

stack.syncLocale(locale:ENGLISH_UNITED_STATES, completion: { ( syncStack:SyncStack, error: NSError) in

})
```

Locale for which sync is needed.

completionBlock called synchronization is done.

## syncLocale:from:completion:

Perform a synchronization operation on locale, and date.

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

NSDate *date = [NSDate date]; 
[[stack syncLocale:ENGLISH_UNITED_STATES from:date completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) 

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

let date = Date.date() 
stack.syncLocale(ENGLISH_UNITED_STATES, from: date, completion: { ( syncStack:SyncStack, error: NSError) in

})
```

Locale for which sync is needed.

Date from where sync data is needed.

completionBlock called synchronization is done.

## syncOnly:locale:from:completion:

Perform a synchronization operation on specified classes, locale and date.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];</span>
NSArray *contentTypeArray = @[@“product”, @“multifield”]; 
NSDate *date = [NSDate date]; 
[[stack syncOnly: contentTypeArray locale:ENGLISH_UNITED_STATES from:date completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) 

}];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let contentTypeArray = [“product”, “multifield”]
let date = Date.date() 
stack.syncOnly(contentTypeArray, locale:ENGLISH_UNITED_STATES, from: date, completion: { ( syncStack:SyncStack, error: NSError) in

})
```

ContentType uids of classes to be expected.

Locale for which sync is needed.

Date from where sync data is needed.

completionBlock called synchronization is done.

## syncOnly:locale:from:publishType:completion:

Perform a synchronization operation on specified classes, locale, date and publishType.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
NSArray *contentTypeArray = @[@“product”, @“multifield”]; 
NSDate *date = [NSDate date]; 
[[stack syncOnly: contentTypeArray locale:ENGLISH_UNITED_STATES from:date publishType:ENTRY_PUBLISHED completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) 

}];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let contentTypeArray = [“product”, “multifield”]
let date = Date.date() 
stack.syncOnly(contentTypeArray, locale:ENGLISH_UNITED_STATES, from: date, publishType:ENTRY_PUBLISHED, completion: { ( syncStack:SyncStack, error: NSError) in

})
```

ContentType uids of classes to be expected.

Locale for which sync is needed.

Date from where sync data is needed.

PublishType for which sync is needed.

completionBlock called synchronization is done.

Readonly property for Stack API Key

Readonly property for Stack of access token/delivery token specific to environment

Read only property of Stack environment to get content.

Read only property of Stack configuration.

## Stack | iOS Delivery SDK | Contentstack

Stack initializes an instance you use to access content types, entries, and assets in the Contentstack iOS Delivery SDK.