ContentType

View as Markdown

ContentType

ContentType provides Entry and Query instance.

setHeader:forKey:

Set a header for Stack.

NameTypeDescription
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

NameTypeDescription
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.

NameTypeDescription
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.

NameTypeDescription
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.

NameTypeDescription
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

})