Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. Read More.
Contentstack - Objective-C Delivery SDK
Objective C SDK for Contentstack's Content Delivery API
Prerequisites
To get started with iOS SDK, you will need the following:
- Latest version of Xcode
- Objective-C and Swift 4.2 and above
- iOS 10 or later.
SDK installation and setup
Contentstack offers five regions North America (NA), Europe (EU), Azure North America (AZURE_NA), Azure Europe (AZURE_EU), and GCP North America(GCP NA) as data centers to store customers' account details and data. These regions are independent of each other and therefore have a dedicated set of instructions to use SDKs offered by Contentstack.
To use SDKs for the Europe, Azure NA, or Azure EU region, you will have to make certain changes in the configuration of the SDK, as detailed below, and the rest of the instructions remain the same.
To add the Contentstack iOS SDK to your existing project, perform the following steps:
SDK Installation:
You can use the SDK using CocoaPods. Add the following line to your Podfile:
pod 'Contentstack'
Then, run the command given below to get the latest release of Contentstack.
pod install
Import header/module:
You can either import the header or the module. Import the header file in Objective-C project using the command given below:
#import <Contentstack/Contentstack.h>
Import the header files as a module too:
- Swift
import Contentstack
- Objective C
@import Contentstack
Quickstart in 5 mins
Initialize SDK
To initialize the SDK, specify application context, the stack’s API key, Delivery token, and name of the environment where you will publish the content, as shown in the snippet below:
- Swift
let stack:Stack = Contentstack.stack(withAPIKey: "API_KEY", accessToken:"DELIVERY_TOKEN", environmentName:"ENVIRONMENT")
- Objective C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
For Setting other Regions:
To set and use the SDK for the Europe, Azure NA, Azure EU, or GCP NA region, refer to the code below:
- Swift
var config: Config = Config(); config.region = ContentstackRegion.EU; //ContentstackRegion.AZURE_NA or ContentstackRegion.AZURE_EU or ContentstackRegion.GCP_NA lt stack:Stack = Contentstack.stack(withAPIKey: "API_KEY", accessToken:"DELIVERY_TOKEN",environmentName:"ENVIRONMENT", config:config)
- Objective C
Config *config = [[Config alloc] init]; config.region = EU; //AZURE_NA or AZURE_EU or GCP_NA Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT" config:config];</p>
Once you have initialized the SDK, you can query entries to fetch the required content.
For Setting the Branch:
If you want to initialize SDK in a particular branch use the code given below:
- Swift
var config: Config = Config(); config.branch = "branch"; let stack:Stack = Contentstack.stack(withAPIKey: "API_KEY", accessToken:"DELIVERY_TOKEN",environmentName:"ENVIRONMENT", config:config)
- Objective C
Config *config = [[Config alloc] init]; config.branch = @"branch"; Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT" config:config];
Basic Queries
Get a Single Entry
To retrieve a single entry from a content type, use the code snippet given below:
- Swift
let stack:Stack = Contentstack.stack(withAPIKey: "API_KEY", accessToken:"DELIVERY_TOKEN", environmentName:"ENVIRONMENT") var contentType:ContentType = stack.contentType(withName: "CONTENT_TYPE_UID") var entry:Entry = contentType.entry(withUID: "ENTRY_UID") entry.fetch { (responseType, error) -> Void in }
- Objective C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Entry *entry = [contentType entryWithUID:@"ENTRY_UID"]; [entry fetch:^(ResponseType type, NSError * _Nullable error) { }];
Get Multiple Entries
To retrieve multiple entries of a particular content type, use the code snippet given below:
- Swift
let stack:Stack = Contentstack.stack(withAPIKey: "API_KEY", accessToken:"DELIVERY_TOKEN", environmentName:"ENVIRONMENT") var contentType:ContentType = stack.contentType(withName: "CONTENT_TYPE_UID") var query: Query = contentType.query() query.find { (responseType, result, error) -> Void in }
- Objective C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query *query = [contentType <span>query</span>]; [query find:^(ResponseType type, QueryResult *result,, NSError * _Nullable error) { }];
Paginating Responses
In a single instance, the Get Multiple Entries query will retrieve only the first 100 items of the specified content type. You can paginate and retrieve the rest of the items in batches using the skip and limit parameters in subsequent requests.
- Swift
let stack:Stack = Contentstack.stack(withAPIKey: "API_KEY", accessToken:"DELIVERY_TOKEN", environmentName:"ENVIRONMENT") var contentType:ContentType = stack.contentType(withName: "CONTENT_TYPE_UID") var query:Query = contentType.query() query.limitObjects(NSNumber(int:20)) query.skipObjects(NSNumber(int: 20)) query.find { (responseType, result!, error!) -> Void in }
- Objective C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query *query = [contentType query</span>]; [query limitObjects:@(20)]; [query skipObjects:@(20)]; [query find:^(ResponseType type, QueryResult *result, NSError *error) { }];
Contentstack
Contentstack class that exposes Stack instance
stackWithAPIKey:accessToken:environmentName:
Create a new Stack instance with stack’s API key, Delivery token, and Environment.
Name | Type | Description |
---|---|---|
apiKey (required) | NSString | Stack API Key. |
deliveryToken (required) | NSString | Environment specific delivery token. |
environment (required) | NSString | Stack environment id to fetch content |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN"
environmentName:@"ENVIRONMENT"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
stackWithAPIKey:accessToken:environmentName:config:
Create a new Stack instance with stack’s API key, Delivery token, Environment and Config.
Name | Type | Description |
---|---|---|
apiKey (required) | NSString | Stack API Key. |
deliveryToken (required) | NSString | Environment specific delivery token. |
environment (required) | NSString | Stack environment id to fetch content |
config (required) | Config | Config of stack. |
Obj-C
Config *config = [[Config alloc] init];
config.host = @"customcontentstack.io";
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN"
environmentName:@"ENVIRONMENT" config:config];
Swift
let config:Config = Config()
config.host = "customcontentstack.io"
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:"ENVIRONMENT", config:config)
cancelAllRequestsOfStack:
Cancel all network request for Stack instance.
Name | Type | Description |
---|---|---|
stack (required) | Stack | Instance of Stack. |
Obj-C
[Contentstack cancelAllRequestsOfStack:stack];
Swift
Contentstack.cancelAllRequestsOfStack(stack)
CachePolicy
POLICIES | DESCTIPTION |
---|---|
NETWORK_ONLY (default) | If you set NETWORK_ONLY as the cache policy, the SDK retrieves data through a network call, and saves the retrieved data in the cache. This is set as the default policy. |
CACHE_ELSE_NETWORK | If you set CACHE_ELSE_NETWORK as the cache policy, the SDK gets data from the cache. However, if it fails to retrieve data from the cache, it makes a network call. |
NETWORK_ELSE_CACHE | If you set NETWORK_ELSE_CACHE as the cache policy, the SDK gets data using a network call. However, if the call fails, it retrieves data from cache. |
CACHE_THEN_NETWORK | If you set CACHE_THEN_NETWORK as the cache policy, the SDK gets data from cache, and then makes a network call. (A success callback will be invoked twice.) |
CACHE_ONLY | If you set CACHE_ONLY as the cache policy, the SDK gets data from the cache. |
ContentstackRegion
Fields
NAME | DESCRIPTION |
---|---|
EU | To specify the EU region. |
US | To specify the US region. |
AZURE_NA | To specify the AZURE NA region |
AZURE_EU | To specify the AZURE EU region |
GCP_NA | To specify the GCP NA region |
Config
Stack configuration for setting stack details.
Name | Type | Description |
---|---|---|
host | NSString | Host name of Contentstack api server. |
region | ContentstackRegion | DB region for your stack. You can choose from four regions namely, NA, EU, Azure NA, and Azure EU. |
version | NSString | API version of Contentstack api server. |
branch | NSString | Branch id for getting content from Stack |
setEarlyAccess
With the setEarlyAccess header support, you can access features that are part of the early access program.
Config *config = [[Config alloc] init];
[config setEarlyAccess:@[@"Taxonomy",@"Teams",@"Terms", @"LivePreview"]];
PublishType
Publish type is to sync specific type of contents:
NAME | DESCRIPTION |
---|---|
ASSET_PUBLISHED | To get only published asset in sync |
ENTRY_PUBLISHED | To get only published entries in sync |
ASSET_UNPUBLISHED | To get only unpublished assets in sync |
ENTRY_UNPUBLISHED | To get only unpublished entries in sync |
ASSET_DELETED | To get only deleted assets in sync |
ENTRY_DELETED | To get only deleted entries in sync |
CONTENT_TYPE_DELETED | To get only content for deleted ContentType in sync |
ResponseType
Publish type is to sync specific type of contents:
NAME | DESCRIPTION |
---|---|
CACHE | Specified response is from the cache. |
NETWORK | Specified response is from the network. |
OrderBy
Publish type is to sync specific type of contents:
NAME | DESCRIPTION |
---|---|
OrderByAscending | Order by ascending |
OrderByDescending | Order by descending |
SyncStack
Represents the result of a sync operation.
Name | Type | Description |
---|---|---|
items | NSArray<NSDictionary<NSString*id> *> | Readonly property contains all the Contents |
skip | int | Readonly property to check skip count |
limit | int | Readonly property to check limit |
totalCount | int | Readonly property to check totalCount |
paginationToken | NSString | Readonly property for paginating sync |
syncToken | NSString | Readonly property to delta sync. |
Stack
Initialize an instance of ‘Stack’
Name | Type | Description |
---|---|---|
apiKey (required) | NSString | Readonly property for Stack API Key |
accessToken (required) | NSString | Readonly property for Stack of access token/delivery token specific to environment |
environment (required) | NSString | Read only property of Stack environment to get content. |
config | Config | Read only property of Stack configuration. |
contentTypeWithName:
Gets the new instance of ContentType object with specified name.
Name | Type | Description |
---|---|---|
contentTypeName (required) | NSString | Uid of the contentType to perform action. |
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")
setHeader:forKey:
Set a header for Stack.
Name | Type | Description |
---|---|---|
headerValue (required) | NSString | The header value |
headerKey (required) | NSString | The header key |
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")
addHeadersWithDictionary:
Set a header for Stack
Name | Type | Description |
---|---|---|
headers (required) | NSDictionary<NSString*,NSString*> | The headers as dictionary which needs to be added to the application. |
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"])
removeHeaderForKey:
Removes a header from this Stack.
Name | Type | Description |
---|---|---|
headerKey (required) | NSString | The header key that needs to be removed. |
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")
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.
Name | Type | Description |
---|---|---|
uid (required) | NSString | Uid of the Asset object to fetch. |
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
})
imageTransformWithUrl:andParams:
Transforms provided image url based on transformation parameters.
Name | Type | Description |
---|---|---|
url (required) | NSString | Url on which transformations to be applied. |
params (required) | NSDictionary<NSString*,id> | 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);
getContentTypes:completion:
Gets all the ContentTypes and its Schema definition.
Name | Type | Description |
---|---|---|
params (required) | NSDictionary<NSString*,id> | params is dictionary of additional parameter |
completionBlock (required) | (NSArray<NSString*> *BUILT_NULLABLE_P contentTypes , NSError *BUILT_NULLABLE_P error) | completionBlock to be called once operation is done. |
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
})
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.
Name | Type | Description |
---|---|---|
completionBlock (required) | (SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error) | completionBlock called synchronization is done. |
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
})
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.
Name | Type | Description |
---|---|---|
token (required) | NSString | Pagination token from where to perform sync |
completionBlock (required) | (SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error) | completionBlock called synchronization is done. |
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
})
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.
Name | Type | Description |
---|---|---|
token (required) | NSString | Sync token from where to perform sync |
completionBlock (required) | (SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error) | completionBlock called synchronization is done. |
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
})
syncOnly:completion:
Perform a synchronization operation on specified classes.
Name | Type | Description |
---|---|---|
contentType (required) | NSString | ContentType uids of classes to be expected. |
completionBlock (required) | (SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error) | completionBlock called synchronization is done. |
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
})
syncFrom:completion:
Perform a synchronization operation on specified date.
Name | Type | Description |
---|---|---|
date (required) | NSDate | Date from where sync data is needed. |
completionBlock (required) | (SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error) | completionBlock called synchronization is done. |
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
})
syncOnly:from:completion:
Perform a synchronization operation on specified classes, and date.
Name | Type | Description |
---|---|---|
contentType (required) | NSString | ContentType uids of classes to be expected. |
date (required) | NSDate | Date from where sync data is needed. |
completionBlock (required) | (SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error) | completionBlock called synchronization is done. |
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
})
syncPublishType:completion:
Perform a synchronization operation on specified publishType.
Name | Type | Description |
---|---|---|
publishType (required) | PublishType | PublishType for which sync is needed. |
completionBlock (required) | (SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error) | completionBlock called synchronization is done. |
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
})
syncLocale:completion:
Perform a synchronization operation on specified locale.
Name | Type | Description |
---|---|---|
locale (required) | NSString | Locale for which sync is needed. |
completionBlock (required) | (SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error) | completionBlock called synchronization is done. |
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
})
syncLocale:from:completion:
Perform a synchronization operation on locale, and date.
Name | Type | Description |
---|---|---|
locale (required) | NSString | Locale for which sync is needed. |
date (required) | NSDate | Date from where sync data is needed. |
completionBlock (required) | (SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error) | completionBlock called synchronization is done. |
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
})
syncOnly:locale:from:completion:
Perform a synchronization operation on specified classes, locale and date.
Name | Type | Description |
---|---|---|
contentType (required) | NSString | ContentType uids of classes to be expected. |
locale (required) | NSString | Locale for which sync is needed. |
date (required) | NSDate | Date from where sync data is needed. |
completionBlock (required) | (SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error) | completionBlock called synchronization is done. |
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
})
syncOnly:locale:from:publishType:completion:
Perform a synchronization operation on specified classes, locale, date and publishType.
Name | Type | Description |
---|---|---|
contentType (required) | NSString | ContentType uids of classes to be expected. |
locale (required) | NSString | Locale for which sync is needed. |
date (required) | NSDate | Date from where sync data is needed. |
publishType (required) | PublishType | PublishType for which sync is needed. |
completionBlock (required) | (SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error) | completionBlock called synchronization is done. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN"
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
ContentType provides Entry and Query instance.
setHeader:forKey:
Set a header for Stack.
Name | Type | Description |
---|---|---|
headerValue (required) | NSString | The header value |
headerKey (required) | NSString | The header key |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
ContentType * contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
[contentType setHeader:@"MyValue" forKey:@"My-Custom-Header"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let contentType = stack.contentTypeWithName("CONTENT_TYPE_UID")
contentType.setHeader("MyValue", forKey: "My-Custom-Header")
addHeadersWithDictionary:
Set a header for Stack ContentType
Name | Type | Description |
---|---|---|
headers (required) | NSDictionary<NSString*,NSString*> | The headers as dictionary which needs to be added to the application. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType * contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
[stack addHeadersWithDictionary:@{@"My-Custom-Header": @"MyValue"}];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let contentType = stack.contentTypeWithName("CONTENT_TYPE_UID")
.addHeadersWithDictionary(["My-Custom-Header":"MyValue"])
removeHeaderForKey:
Removes a header from this Stack.
Name | Type | Description |
---|---|---|
headerKey (required) | NSString | The header key that needs to be removed. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
ContentType * contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
[contentType removeHeaderForKey:@"key"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let contentType = stack.contentTypeWithName("CONTENT_TYPE_UID")
.removeHeaderForKey("key")
entryWithUID:
Gets the new instance of Entry object with specified UID.
Name | Type | Description |
---|---|---|
uid (required) | NSString | Uid of the Entry object to fetch. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType * contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry *entryObj = [contentType entryWithUID:@"ENTRY_UID"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let contentType = stack.contentTypeWithName("CONTENT_TYPE_UID")
let entryObj:Entry = contentType.entryWithUID("ENTRY_UID")
query
Represents a Query on ‘ContentType’ which can be executed to retrieve entries that pass the query condition
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType * contentType = [stack contentTypeWithName:@"<content_type_id>"]
Query *queryObj = [contentTypeObj query];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let contentType = stack.contentTypeWithName("<content_type_id>")
var queryObj:Query = contentTypeObj.query()
fetch:completion:
Gets ContentType Schema definition.
Name | Type | Description |
---|---|---|
params (required) | NSDictionary<NSString*,id> | Fetch query parameters |
completionBlock (required) | (void ( ^ ) ( NSDictionary<NSString*,NSString*> *BUILT_NULLABLE_P contentType , NSError *BUILT_NULLABLE_P error )) | Block to be called once operation is done. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
ContentType * contentType = [stack contentTypeWithName:@"<content_type_id>"];
[contentType fetch:params completion:^(NSDictionary * _Nullable contentType, NSError * _Nullable error)
}];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let contentType = stack.contentTypeWithName("<content_type_id>")
contentType.fetch(params, { (contentType, error) in
})
Asset
Retrieves a single asset, specify its UID.
Name | Type | Description |
---|---|---|
fileName | NSString | Readonly property to check fileName of asset |
fileSize | NSString | Readonly property to check fileSize of asset |
fileType | NSString | Readonly property to check type of asset |
uid | NSString | Readonly property to check value of asset’s uid |
url | NSString | Readonly property to check value of asset’s url |
tags | NSArray<NSString*> | Readonly property to check tags of asset |
properties | NSDictionary<NSString*id> | Readonly property to get data of entry. |
configureWithDictionary:
Configure user properties with built object info.
Name | Type | Description |
---|---|---|
dictionary (required) | NSDictionary<NSString*,id*> | The as dictionary which needs to be added to the application. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
Asset* asset = [stack assetWithUID:@"ASSET_UID"];
[asset configureWithDictionary:@{@"key_name":@"MyValue"}];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var asset:Asset = stack.assetWithUID("ASSET_UID")
asset.configureWithDictionary(["key_name":"MyValue"])
addParamKey:andValue:
This method adds key and value to an Asset.
Name | Type | Description |
---|---|---|
key (required) | NSString | The key as string which needs to be added to an Asset |
value (required) | NSString | The value as string which needs to be added to an Asset |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
Asset* asset = [stack assetWithUID:@"ASSET_UID"];
[asset addParamKey:@"key" andValue:@"value"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var asset:Asset = stack.assetWithUID("ASSET_UID")
asset.addParamKey("key", andValue:"value")
setHeader:forKey:
Set a header for Asset
Name | Type | Description |
---|---|---|
headerValue (required) | NSString | The header value |
headerKey (required) | NSString | The header key |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
Asset* asset = [stack assetWithUID:@"ASSET_UID"];
[asset setHeader:@"MyValue" forKey:@"My-Custom-Header"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var asset:Asset = stack.assetWithUID("ASSET_UID")
asset.setHeader("MyValue", forKey: "My-Custom-Header")
addHeadersWithDictionary:
Set a header for Asset
Name | Type | Description |
---|---|---|
headers (required) | NSDictionary<NSString*,NSString*> | The headers as dictionary which needs to be added to the application. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
Asset* asset = [stack assetWithUID:@"ASSET_UID"];
[asset addHeadersWithDictionary:@{@"My-Custom-Header": @"MyValue"}];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var asset:Asset = stack.assetWithUID("ASSET_UID")
asset.addHeadersWithDictionary(["My-Custom-Header":"MyValue"])
removeHeaderForKey:
Removes a header from this Asset
Name | Type | Description |
---|---|---|
headerKey (required) | NSString | The header key that needs to be removed. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
Asset* asset = [stack assetWithUID:@"ASSET_UID"];
[asset removeHeaderForKey:@"key"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var asset:Asset = stack.assetWithUID("ASSET_UID")
asset.removeHeaderForKey("key")
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"];
Asset* asset = [stack assetWithUID:@"ASSET_UID"];
[asset includeFallback];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var asset:Asset = stack.assetWithUID("ASSET_UID")
asset.includeFallback()
includeBranch
Retrieve the branch for the published content.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
Asset* asset = [stack assetWithUID:@"ASSET_UID"];
[asset includeBranch];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var asset:Asset = stack.assetWithUID("ASSET_UID")
asset.
()
fetch:
Fetches an asset asynchronously provided asset UID.
Name | Type | Description |
---|---|---|
completionBlock (required) | (void ( ^ ) ( ResponseType type , NSError *BUILT_NULLABLE_P error )) | Block to be called once operation is done. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
Asset * asset = [stack assetWithUID:@"ASSET_UID"];
[asset fetch:^(ResponseType type, NSError *error)
}];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let asset = stack.assetWithUID("ASSET_UID")
asset.fetch({ (responseType, error!) -> in
})
AssetLibrary
AssetLibrary class to fetch details of files on Contentstack server.
Name | Type | Description |
---|---|---|
cachePolicy | CachePolicy | property to assign cache policy like CACHE_THEN_NETWORK, NETWORK_ELSE_CACHE, NETWORK_ONLY, etc. |
setHeader:forKey:
Set a header for AssetLibrary
Name | Type | Description |
---|---|---|
headerValue (required) | NSString | The header value |
headerKey (required) | NSString | The header key |
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")
addHeadersWithDictionary:
Set a header for AssetLibrary
Name | Type | Description |
---|---|---|
headers (required) | NSDictionary<NSString*,NSString*> | The headers as dictionary which needs to be added to the application. |
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"])
removeHeaderForKey:
Removes a header from this AssetLibrary
Name | Type | Description |
---|---|---|
headerKey (required) | NSString | The header key that needs to be removed. |
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")
sortWithKey:orderBy:
Sorts the assets in the given order on the basis of the specified field.
Name | Type | Description |
---|---|---|
key (required) | NSString | field uid based on which the ordering should be done. |
order (required) | OrderBy | ascending or descending order in which results should come. |
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)
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.
Name | Type | Description |
---|---|---|
locale (required) | NSString | Language enum for all language available. |
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")
fetchAll:
This method provides all the assets.
Name | Type | Description |
---|---|---|
completionBlock (required) | (void ( ^ ) ( ResponseType type , NSArray<Asset*> *BUILT_NULLABLE_P result , NSError *BUILT_NULLABLE_P error )) | Block to be called once operation is done. |
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
})
where:
The where() method retrieves the assets from the stack using any other field UID of the assets.
Name | Type | Description |
---|---|---|
field | NSString | Field UID of the Asset |
value | NSObject | The value to match for the field. |
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)")
}
}
Entry
An initializer is responsible for creating Entry object.
Name | Type | Description |
---|---|---|
uid | NSString | Readonly property to check value of entry’s uid |
deleted | BOOL | Readonly property to check if entry is deleted. |
tags | NSArray<NSString*> | Readonly property to check tags of entry |
contentTypeName | NSString | Readonly property to check ContentType name of entry |
title | NSString | Readonly property to check title of entry. |
url | NSString | Readonly property to check url of entry. |
locale | NSString | Readonly property to check Language of entry |
createdAt | NSDate | Readonly property to check createAt of entry |
createdBy | NSString | Readonly property to check createdBy of entry |
updatedAt | NSDate | Readonly property to check updatedAt of entry |
updatedBy | NSString | Readonly property to check updatedBy of entry |
deletedAt | NSDate | Readonly property to check deletedAt of entry |
deletedBy | NSString | Readonly property to check deletedBy of entry |
cachePolicy | CachePolicy | The property to assign cache policy like CACHE_THEN_NETWORK, NETWORK_ELSE_CACHE, NETWORK_ONLY, etc. |
properties | NSDictionary<NSString*id> | Readonly property to get data of entry. |
setHeader:forKey:
Set a header for Entry
Name | Type | Description |
---|---|---|
headerValue (required) | NSString | The header value |
headerKey (required) | NSString | The header key |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry setHeader:@"MyValue" forKey:@"My-Custom-Header"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.setHeader("MyValue", forKey: "My-Custom-Header")
addHeadersWithDictionary:
Set a header for Entry
Name | Type | Description |
---|---|---|
headers (required) | NSDictionary<NSString*,NSString*> | The headers as dictionary which needs to be added to the application. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry addHeadersWithDictionary:@{@"My-Custom-Header": @"MyValue"}];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.addHeadersWithDictionary(["My-Custom-Header":"MyValue"])
removeHeaderForKey:
Removes a header from this Entry.
Name | Type | Description |
---|---|---|
headerKey (required) | NSString | The header key that needs to be removed. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry removeHeaderForKey:@"key"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.removeHeaderForKey("key")
configureWithDictionary:
Configure user properties with built object info.
Name | Type | Description |
---|---|---|
dictionary (required) | NSDictionary<NSString*,id*> | The as dictionary which needs to be added to the application. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry configureWithDictionary:@{@"key_name":@"MyValue"}];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
var hashKey:Bool = entry.hasKey("key")
entry.configureWithDictionary(["key_name":"MyValue"])
hasKey:
Checks whether an entry has a given property.
Name | Type | Description |
---|---|---|
key (required) | NSString | The property to be checked |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
BOOL hashKey = [entry hasKey:@"key"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
var hashKey:Bool = entry.hasKey("key")
assetForKey:
Get the info of the specified key of Asset object and returns instance of Assets.
Name | Type | Description |
---|---|---|
key (required) | NSString | Key containing the reference value of Asset |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
Asset *asset = [entry assetForKey:@"asset"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
let asset = entry.assetForKey("asset")
assetsForKey:
Get the array containing instance of Assets mentioned in key specified.
Name | Type | Description |
---|---|---|
key (required) | NSString | Key containing the colection reference value of Assets. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
NSArray *assetArray = [entry assetsForKey:@"asset"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
let assetArray = entry.assetsForKey("asset")
groupForKey:
Get the info of the specified key of Group object and returns instance of Group.
Name | Type | Description |
---|---|---|
key (required) | NSString | Key containing the value of Group |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
Group *detailsGroup = [entry groupForKey:@"details"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
let detailsGroup = entry.groupForKey("details")
groupsForKey:
Get the info of the specified key of content type and returns array of Group.
Name | Type | Description |
---|---|---|
key (required) | NSString | Key containing the value of Group array |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry groupsForKey:@"addresses"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.groupsForKey("addresses")
HTMLStringForMarkdownKey:
Converts Markdown to String of HTML String for specified key
Name | Type | Description |
---|---|---|
key (required) | NSString | Key is Multiple Markdown Parameter |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry HTMLStringForMarkdownKey:@"multiple_markdown"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.HTMLStringForMarkdownKey("Multiple_markdown")
HTMLArrayForMarkdownKey:
Converts Markdown to Array of HTML String for specified key.
Name | Type | Description |
---|---|---|
key (required) | NSString | Key is Multiple Markdown Parameter |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry HTMLArrayForMarkdownKey:@"multiple_markdown"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.HTMLArrayForMarkdownKey("Multiple_markdown")
includeSchema
This method also includes the schema for the entries returned in the response.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry includeSchema];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.includeSchema()
includeContentType
This method also includes the contenttype for the entries returned in the response.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry includeContentType];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.includeContentType()
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"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry includeFallback];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.includeFallback()
includeBranch
Retrieve the branch for the published content.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry includeBranch];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.includeBranch()
includeReferenceContentTypeUid
This method also includes the content type UIDs of the referenced entries returned in the response.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry includeReferenceContentTypeUid];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.includeReferenceContentTypeUid()
includeEmbeddedItems
Include Embedded Objects (Entries and Assets) along with entry/entries details.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry includeEmbeddedItems];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.includeEmbeddedItems()
includeOnlyFields:
Specifies an array of ‘only’ keys in BASE object that would be included in the response.
Name | Type | Description |
---|---|---|
fieldUIDs (required) | NSArray | Array of the ‘only’ keys to be included in response. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry includeOnlyFields:@["name"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.includeOnlyFields(["name"])
includeAllFieldsExcept:
Specifies an array of keys in reference class object that would be ‘excluded’ from the response.
Name | Type | Description |
---|---|---|
fieldUIDs (required) | NSArray | Array of keys to be excluded from the response. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry includeAllFieldsExcept:@["name"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.includeAllFieldsExcept(["name"])
includeRefFieldWithKey:
Include reference objects with given key in response.
Name | Type | Description |
---|---|---|
key (required) | NSArray | Array of reference keys to include in response. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry includeRefFieldWithKey:@[@"detail"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.includeRefFieldWithKey(["detail"])
includeRefFieldWithKey:andOnlyRefValuesWithKeys:
Specifies an array of ‘only’ keys in reference class object that would be included in the response.
Name | Type | Description |
---|---|---|
key (required) | NSString | Key who has reference to some other class object. |
values (required) | NSArray | Array of the ‘only’ reference keys to be included in response. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry* entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry includeRefFieldWithKey:@[@"detail"] andOnlyRefValuesWithKeys:@[@"description"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var entry: Entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.includeRefFieldWithKey(["detail"], andOnlyRefValuesWithKeys:["description"])
includeRefFieldWithKey:excludingRefValuesWithKeys:
Specifies an array of keys in reference class object that would be ‘excluded’ from the response.
Name | Type | Description |
---|---|---|
key (required) | NSString | Key who has reference to some other class object. |
values (required) | NSArray | Array of the ‘only’ reference keys to be ‘excluded’ from the response. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry* entry = [stack includeRefFieldWithKey:@[@"detail"] excludingRefValuesWithKeys:@[@"description"];
[entry addParamKey:@"key" andValue:@"value"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var entry: Entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.includeRefFieldWithKey(["detail"], excludingRefValuesWithKeys:["description"])
addParamKey:andValue:
This method adds key and value to an Entry.
Name | Type | Description |
---|---|---|
key (required) | NSString | The key as string which needs to be added to an Entry |
value (required) | NSString | The value as string which needs to be added to an Entry |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry* entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry addParamKey:@"key" andValue:@"value"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var entry: Entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.addParamKey("key", andValue:"value")
fetch:
Fetches an entry asynchronously provided entry UID.
Name | Type | Description |
---|---|---|
completionBlock (required) | (void ( ^ ) ( ResponseType type , NSError *BUILT_NULLABLE_P error )) | Block to be called once operation is done. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Entry * entry = [contentType entryWithUID:@"ENTRY_UID"];
[entry fetch:^(ResponseType type, NSError *error)
}];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let entry = stack.contentTypeWithName("CONTENT_TYPE_UID").entryWithUID("ENTRY_UID")
entry.fetch({ (responseType, error!) -> in
})
Variants
The variants method retrieves details of a specific entry variant or an array of entry variants based on the applied query.
Name | Type | Description |
---|---|---|
variantUid/variantAlias | variantUids/variantAliases (required) | NSString | NSArray | Enter the UID of the variant |
Example 1:
#import <Contentstack/Contentstack.h>;
Stack* stack = [Contentstack stackWithAPIKey:<api_key> accessToken:<delivery_token> environmentName:<env_name>];
ContentType* ct = [stack contentTypeWithName:<ct_uid>];
Entry* entry = [ct entryWithUid:<entry_uid>];
[entry variantUid:<variant_uid/variant-alias>];
[entry fetch:^(ResponseType type, NSError *error) {
if(error) {
// catch error
} else {
// get response
}
}];
Example 2:
#import <Contentstack/Contentstack.h>;
Stack* stack = [Contentstack stackWithAPIKey:<api_key> accessToken:<delivery_token> environmentName:<env_name>];
ContentType* ct = [stack contentTypeWithName:<ct_uid>];
Entry* entry = [ct entryWithUid:<entry_uid>];
[entry variantUids/variantAliases:[@"variantUid1/variantAlias1", @"variantUid2/variantAlias2",@"variantUid3/variantAlias3"]];
[entry fetch:^(ResponseType type, NSError *error) {
if(error) {
// catch error
} else {
// get response
}
}];
Query
An initializer is responsible for creating Query object.
Name | Type | Description |
---|---|---|
cachePolicy | CachePolicy | The property to assign cache policy like CACHE_THEN_NETWORK, NETWORK_ELSE_CACHE, NETWORK_ONLY, etc. |
setHeader:forKey:
Set a header for Query
Name | Type | Description |
---|---|---|
headerValue (required) | NSString | The header value |
headerKey (required) | NSString | The header key |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query setHeader:@"MyValue" forKey:@"My-Custom-Header"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.setHeader("MyValue", forKey: "My-Custom-Header")
addHeadersWithDictionary:
Set a header for Query
Name | Type | Description |
---|---|---|
headers (required) | NSDictionary<NSString*,NSString*> | The headers as dictionary which needs to be added to the application. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query addHeadersWithDictionary:@{@"My-Custom-Header": @"MyValue"}];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.addHeadersWithDictionary(["My-Custom-Header":"MyValue"])
removeHeaderForKey:
Removes a header from this Query.
Name | Type | Description |
---|---|---|
headerKey (required) | NSString | The header key that needs to be removed. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query removeHeaderForKey:@"key"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.removeHeaderForKey("key")
locale:
This method provides all the entries for the specified language in the response.
Name | Type | Description |
---|---|---|
locale (required) | NSString | Language enum for all language available. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query locale:@“en-us”];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.locale(“en-us”)
tags:
This method provides only the entries that contain tags matching the ones mentioned in the function.
Name | Type | Description |
---|---|---|
tagsArray (required) | NSArray<NSString*> | An array of tags that are to be included for the key |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query tags:@[@"phone", @"laptop"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.tags(["phone", "laptop"])
orWithSubqueries:
This method performs the OR operation on the specified query objects and provides only the matching entries.
Name | Type | Description |
---|---|---|
queries (required) | NSArray<Query*> | Array of queries to be taken into consideration. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query *query1 = [contentType query];
[query1 whereKey:@"total_hits" greaterThanOrEqualTo:@(800)];
Query *query2 = [contentType query];
[query2 whereKey:@"total_hits" lessThanOrEqualTo:@(1200)];
Query * query = [contentType query];
[query orWithSubqueries:@[query1, query2]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var query1:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query1.whereKey("total_hits", greaterThanOrEqualTo:800)
var query2:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query2.whereKey("total_hits", equalTo:1200)
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.orWithSubqueries([query1, query2])
andWithSubqueries:
This method performs the AND operation on the specified query objects and provides only the matching entries.
Name | Type | Description |
---|---|---|
queries (required) | NSArray<Query*> | Array of queries to be taken into consideration. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query *query1 = [contentType query];
[query1 whereKey:@"total_hits" greaterThanOrEqualTo:@(800)];
Query *query2 = [contentType query];
[query2 whereKey:@"total_hits" lessThanOrEqualTo:@(1200)];
Query * query = [contentType query];
[query andWithSubqueries:@[query1, query2]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var query1:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query1.whereKey("total_hits", greaterThanOrEqualTo:800)
var query2:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query2.whereKey("total_hits", equalTo:1200)
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.andWithSubqueries([query1, query2])
orderByAscending:
Sorts the provided entries in the ascending order on the basis of the specified field.
Name | Type | Description |
---|---|---|
key (required) | NSString | The field uid based on which the ordering should be done. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query orderByAscending:@"updated_at"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.orderByAscending("updated_at")
orderByDescending:
Sorts the provided entries in the descending order on the basis of the specified field.
Name | Type | Description |
---|---|---|
key (required) | NSString | The field uid based on which the ordering should be done. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query orderByDescending:@"updated_at"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.orderByDescending("updated_at")
objectsCount
Provides only the number of entries with values matching the specified values for a field.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query objectsCount];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.objectsCount()
includeContentType
This method also includes the contenttype for the entries returned in the response.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeContentType];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeContentType()
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"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeFallback];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeFallback()
includeBranch
Retrieve the branch for the published content.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeBranch];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeBranch()
includeReferenceContentTypeUid
This method also includes the content type UIDs of the referenced entries returned in the response.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeReferenceContentTypeUid];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeReferenceContentTypeUid()
includeEmbeddedItems
Include Embedded Objects (Entries and Assets) along with entry/entries details.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeEmbeddedItems];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeEmbeddedItems()
includeCount
This method also includes the total number of entries returned in the response.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeCount];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeCount()
limitObjects:
This method limits the response by providing only the specified number of entries.
Name | Type | Description |
---|---|---|
number (required) | NSNumber | Number of entries to be returned |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query limitObjects:@(5)];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.limitObjects(NSNumber(int:5))
skipObjects:
This method provide response by skipping only the specified number of entries.
Name | Type | Description |
---|---|---|
number (required) | NSNumber | Number of entries to be skipped before returned. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query skipObjects:@(5)];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.skipObjects(NSNumber(int:5))
addQueryWithKey:andValue:
Include custom query using a key and a value.
Name | Type | Description |
---|---|---|
key (required) | NSString | The name of the key to be added. |
value (required) | id | The value for the query key. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query addQueryWithKey:@"key_name" andValue:@"MyValue"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.addQueryWithKey("key_name", andValue:"MyValue")
addQueryParams:
A custom dictionary can be provided to a query that can specify the conditions for retrieving objects.
Name | Type | Description |
---|---|---|
queryDict (required) | NSDictionary<NSString*,id> | A dictionary with all the necessary conditions for retrieving objects. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query addQueryParams:@{@"Query_Key":@"Query Value"}];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.addQueryParams(["Query_Key":"Query Value"])
removeQueryWithKey:
Removes custom query.
Name | Type | Description |
---|---|---|
key (required) | NSString | The name of the query. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query removeQueryWithKey:@"Query_Key"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.removeQueryWithKey("Query_Key")
whereKey:equalTo:
This method provides only the entries matching the specified value for a field.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the field that is to be taken into consideration |
object (required) | id | The value used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"title" equalTo:@"Welcome"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", equalTo:"Welcome")
whereKey:notEqualTo:
This method provides only the entries with values not equal to the specified value for a field.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the field that is to be taken into consideration |
object (required) | id | The value used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"title" notEqualTo:@"Welcome"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", notEqualTo:"Welcome")
whereKey:lessThan:
This method provides only the entries with a values less than the specified value for a field.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the field that is to be taken into consideration |
object (required) | id | The value used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"created_at" lessThan:@"2015-03-12"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("created_at", lessThan:"2015-03-12")
whereKey:greaterThan:
This method provides only the entries with values greater than the specified value for a field.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the field that is to be taken into consideration |
object (required) | id | The value used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"created_at" greaterThan:@"2015-03-12"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("created_at", greaterThan:"2015-03-12")
whereKey:lessThanOrEqualTo:
This method provides only the entries with values less than or equal to the specified value for a field.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the field that is to be taken into consideration |
object (required) | id | The value used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"created_at" lessThanOrEqualTo:@"2015-03-12"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("created_at", lessThanOrEqualTo:"2015-03-12")
whereKey:greaterThanOrEqualTo:
This method provides only the entries with values greater than or equal to the specified value for a field.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the field that is to be taken into consideration |
object (required) | id | The value used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"created_at" greaterThanOrEqualTo:@"2015-03-12"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("created_at", greaterThanOrEqualTo:"2015-03-12")
whereKey:containedIn:
This method provides only the entries with values matching the specified values for a field.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the field that is to be taken into consideration |
array (required) | NSArray | An array of values that are to be used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"title" containedIn:@["Demo", @"Welcome"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", containedIn:["Demo", "Welcome"])
whereKey:notContainedIn:
This method provides only the entries that do not contain values matching the specified values for a field.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the field that is to be taken into consideration |
array (required) | NSArray | An array of values that are to be used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"title" notContainedIn:@["Demo", @"Welcome"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", notContainedIn:["Demo", "Welcome"])
whereKeyExists:
This method provides only the entries that contains the field matching the specified field uid.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the field that is to be taken into consideration |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKeyExists:@"introduction"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKeyExists("introduction")
whereKeyDoesNotExist:
This method provides only the entries that do not contain the field matching the specified field uid.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the field that is to be taken into consideration |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKeyDoesNotExist:@"introduction"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKeyDoesNotExist("introduction")
whereKey:matchesRegex:
This method provides only the entries matching the regular expression for the specified field.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the field that is to be taken into consideration |
regex (required) | NSString | The value used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"title" matchesRegex:@"^wel"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", matchesRegex:"^wel")
whereKey:matchesRegex:modifiers:
This method provides only the entries matching the regular expression for the specified field.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the field that is to be taken into consideration |
regex (required) | NSString | The value used to match or compare |
modifier (required) | NSString | Modifiers for regex options. Specify ‘i’ as the option to ignore the case. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"title" matchesRegex:@"^wel" modifiers:@"i"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", matchesRegex:"^wel", modifiers:"i")
whereKey:in:
This method provides only the entries matching the Query.
Name | Type | Description |
---|---|---|
key (required) | NSString | Reference Uid of the field that is to be taken into consideration. |
query (required) | Query | Querie to be taken into consideration |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
Query * reference = [contentType query];
[reference whereKey:@"name" equalTo:@"Author"];
[query whereKey:@"author" in:reference];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
var reference:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
reference.whereKey("name", equalTo:"Author")
query.whereKey("author", in:reference)
whereKey:notIn:
This method provides only the entries matching the Query.
Name | Type | Description |
---|---|---|
key (required) | NSString | Reference Uid of the field that is to be taken into consideration. |
query (required) | Query | Querie to be taken into consideration |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
Query * reference = [contentType query];
[reference whereKey:@"name" equalTo:@"Author"];
[query whereKey:@"author" notIn:reference];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
var reference:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
reference.whereKey("name", equalTo:"Author")
query.whereKey("author", notIn:reference)
onlyFields:
This method provides only the entries that match the specified field uids and corresponding values.
Name | Type | Description |
---|---|---|
fieldUIDs (required) | NSArray | An array of values that are to be included for the key |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query onlyFields:@[@"attachments"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.onlyFields(["attachments"])
exceptFields:
This method provides all entries except those that match the specified field uids and corresponding values.
Name | Type | Description |
---|---|---|
fieldUIDs (required) | NSArray | An array of values that are to be included for the key |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query exceptFields:@[@"attachments"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.exceptFields(["attachments"])
includeReferenceFieldWithKey:
This method provides all entries that also contain data from the referred entry in the specified field.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the reference field that is to be taken into consideration |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeReferenceFieldWithKey:@"entry_a"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeReferenceFieldWithKey(@"entry_a")
includeReferenceFieldWithKey:onlyFields:
This method provides all entries including referred entry containing only specified fields.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the reference field that is to be taken into consideration |
fieldUIDs (required) | NSArray<NSString*> * | Uid of the reference field that is to be taken into consideration |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeReferenceFieldWithKey:@"entry_a" onlyFields:@[@"attachments"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeReferenceFieldWithKey(@"entry_a", onlyFields:["attachments"])
includeReferenceFieldWithKey:excludingFields:
This method provides all entries including referred entry containing all fields except specified fields.
Name | Type | Description |
---|---|---|
key (required) | NSString | Uid of the reference field that is to be taken into consideration |
fieldUIDs (required) | NSArray<NSString*> * | Uid of the reference field that is to be taken into consideration |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeReferenceFieldWithKey:@"entry_a" excludingFields:@[@"attachments"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeReferenceFieldWithKey(@"entry_a", excludingFields:["attachments"])
addParamKey:andValue:
This method provides all the entries from a specified ContentType.
Name | Type | Description |
---|---|---|
key (required) | NSString | The key as string which needs to be added to the Query |
value (required) | The value as string which needs to be added to the Query |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query addParamKey:@"key" andValue:@"value"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.addParamKey("key", andValue:"value")
find:
This method provides all the entries from a specified ContentType.
Note: By default, the limit for response details per request is 100, with the maximum limit set at 250.
Name | Type | Description |
---|---|---|
completionBlock (required) | (void ( ^ ) ( ResponseType type , Entry *BUILT_NULLABLE_P entry , NSError *BUILT_NULLABLE_P error )) | Block to be called once operation is done. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query find:^(ResponseType type, Entry *entry, NSError *error){
}];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.find({(responseType, entry!, error!) -> in
})
findOne:
This method provides the first entry from a specified ContentType.
Name | Type | Description |
---|---|---|
completionBlock (required) | (void ( ^ ) ( ResponseType type , Entry *BUILT_NULLABLE_P entry , NSError *BUILT_NULLABLE_P error )) | Block to be called once operation is done. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query findOne:^(ResponseType type, Entry *entry, NSError *error){
}];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.findOne({(responseType, entry!, error!) -> in
})
Taxonomy
Taxonomy helps you categorize pieces of content within your stack to facilitate easy navigation and retrieval of information.
initWithStack
The initWithStack method initializes a new instance of the Taxonomy class using the specified Stack.
Name | Type | Description |
---|---|---|
stack (required) | String | The stack instance for making API requests |
Objective C:
Stack *stack = [Contentstack stackWithAPIKey:@"api_key"
deliveryToken:@"delivery_token"
environment:@"environment"];
Taxonomy *taxonomy = [[Taxonomy alloc] initWithStack:stack];
Swift:
let stack = Contentstack.stack(apiKey: "api_key",
deliveryToken: "delivery_token",
environment: "environment")
let taxonomy = Taxonomy(stack: stack)
query
The querymethod generates a new Query instance for the taxonomy.
Objective C:
Taxonomy *taxonomy = [[Taxonomy alloc] initWithStack:stack]; Query *query = [taxonomy query];
Swift:
let taxonomy = Taxonomy(stack: stack) let query = taxonomy.query()
whereKey:equalTo:
The whereKey:equalTo: method adds a condition to filter entries where the specified key matches the provided value.
Name | Type | Description |
---|---|---|
key | NSString* | The key of the field to query for the desired data. |
value | id | The value to match |
Objective C:
Taxonomy *taxonomy = [[Taxonomy alloc] initWithStack:stack];
Query *query = [taxonomy query];
[query whereKey:@"title" equalTo:@"Sample Taxonomy"];
Swift:
let taxonomy = Taxonomy(stack: stack)
let query = taxonomy.query()
query.whereKey("title", equalTo: "Sample Taxonomy")
fetch:completion:
The whereKey:equalTo: method adds a condition to filter entries where the specified key matches the provided value.
Name | Type | Description |
---|---|---|
params | NSDictionary<NSString*, id>* | Optional parameters for the request |
completionBlock | Block | Completion handler with result or error |
Objective C:
NSDictionary *params = @{ @"include_count":@(true), @"include_global_field_schema": @(true) };
[taxonomy fetch:params completion:^(NSDictionary *entries, NSError *error) {
if (error)
{ NSLog(@"Error: %@", error.localizedDescription);
return;
}
NSLog(@"Fetched entries: %@", entries);
}];
Swift:
let params = [ "include_count": true, "include_global_field_schema": true ] as [String : Any]
taxonomy.fetch(params) { (entries, error) in
if let error = error {
print("Error: \(error.localizedDescription)")
return }
if let entries = entries {
print("Fetched entries: \(entries)")
}
}
findTaxonomy:
The findTaxonomy: method executes a query to fetch taxonomy entries that match specified query conditions.
Name | Type | Description |
---|---|---|
completionBlock | completion | Returns (ResponseType, QueryResult*, NSError*) |
Objective C:
Query *query = [taxonomy query];
[query whereKey:@"taxonomies.one" equalTo:@"term_one"];
[query findTaxonomy:^(ResponseType type, QueryResult *result, NSError *error) {
if (error) {
NSLog(@"Error: %@", error.localizedDescription);
return;
}
NSArray *entries = [result getResult];
NSLog(@"Fetched entries: %@", entries);
}];
Swift:
let query = taxonomy.query()
query.whereKey("taxonomies.one", equalTo: "term_one")
query.findTaxonomy { (type, result, error) in
if let error = error {
print("Error: \(error.localizedDescription)")
return
}
if let entries = result?.getResult() {
print("Fetched entries: \(entries)")
}
}
orWithSubqueries:
The orWithSubqueries method combines multiple queries using AND condition.
Name | Type | Description |
---|---|---|
subqueries | NSArray<Query*>* | Array of Query objects to combine with OR |
Objective C:
Query *query1 = [taxonomy query];
[query1 whereKey:@"taxonomies.one" equalTo:@"term_one"];
Query *query2 =[taxonomy query];
[query2 whereKey:@"taxonomies.two" equalTo:@"term_two"];
Query *mainQuery = [taxonomy query];
[mainQuery orWithSubqueries:@[query1, query2]];
Swift:
let query1 = taxonomy.query()
query1.whereKey("taxonomies.one", equalTo: "term_one")
let query2 = taxonomy.query()
query2.whereKey("taxonomies.two", equalTo: "term_two")
let mainQuery = taxonomy.query()
mainQuery.orWithSubqueries([query1, query2])
andWithSubqueries:
The andWithSubqueries: method combines multiple queries using AND condition.
Name | Type | Description |
---|---|---|
subqueries | NSArray<Query*>* | Array of Query objects to combine with AND |
Objective C:
Query *query1 = [taxonomy query];
[query1 whereKey:@"taxonomies.one" equalTo:@"term_one"];
Query *query2 =[taxonomy query];
[query2 whereKey:@"taxonomies.two" equalTo:@"term_two"];
Query *mainQuery = [taxonomy query];
[mainQuery andWithSubqueries:@[query1, query2]];
Swift:
let query1 = taxonomy.query()
query1.whereKey("taxonomies.one", equalTo: "term_one")
let query2 = taxonomy.query()
query2.whereKey("taxonomies.two", equalTo: "term_two")
let mainQuery = taxonomy.query()
mainQuery.andWithSubqueries([query1, query2])