Asset Class Reference

Inherits from NSObject
Declared in Asset.h

Properties

  fileName

Readonly property to check fileName of asset

@property (nonatomic, copy, readonly) NSString *fileName

Declared In

Asset.h

  fileSize

Readonly property to check fileSize of asset

@property (nonatomic, assign, readonly) unsigned int fileSize

Declared In

Asset.h

  fileType

Readonly property to check type of asset

@property (nonatomic, copy, readonly) NSString *fileType

Declared In

Asset.h

  uid

Readonly property to check value of asset’s uid

@property (nonatomic, copy, readonly) NSString *uid

Declared In

Asset.h

  url

Readonly property to check value of asset’s url

@property (nonatomic, copy, readonly) NSString *url

Declared In

Asset.h

  tags

Readonly property to check tags of asset

@property (nonatomic, copy, readonly) NSArray *tags

Declared In

Asset.h

  createdAt

Readonly property to check createAt of asset

@property (nonatomic, copy, readonly) NSDate *createdAt

Declared In

Asset.h

  createdBy

Readonly property to check createdBy of asset

@property (nonatomic, copy, readonly) NSString *createdBy

Declared In

Asset.h

  updatedAt

Readonly property to check updatedAt of asset

@property (nonatomic, copy, readonly) NSDate *updatedAt

Declared In

Asset.h

  updatedBy

Readonly property to check updatedBy of asset

@property (nonatomic, copy, readonly) NSString *updatedBy

Declared In

Asset.h

  deletedAt

Readonly property to check deletedAt of asset

@property (nonatomic, copy, readonly) NSDate *deletedAt

Declared In

Asset.h

  deletedBy

Readonly property to check deletedBy of asset

@property (nonatomic, copy, readonly) NSString *deletedBy

Declared In

Asset.h

  properties

Readonly property to get data of entry.

@property (nonatomic, copy, readonly) NSDictionary *properties

Declared In

Asset.h

  cachePolicy

property to assign cache policy like CACHE_THEN_NETWORK, NETWORK_ELSE_CACHE, NETWORK_ONLY, etc.

@property (nonatomic, assign) CachePolicy cachePolicy

Declared In

Asset.h

Configuring manually

– configureWithDictionary:

Configure user properties with built object info.

- (void)configureWithDictionary:(NSDictionary *)dictionary

Parameters

dictionary

User Info

Discussion

 //Obj-C
 [assetObj configureWithDictionary:@{@"key_name":@"MyValue"}];

 //Swift
 assetObj.configureWithDictionary(["key_name":"MyValue"])

Declared In

Asset.h

Manually set headers

– setHeader:forKey:

Set a header for Asset

- (void)setHeader:(NSString *)headerValue forKey:(NSString *)headerKey

Parameters

headerValue

The header key

headerKey

The header value

Discussion

 //'blt5d4sample2633b' is a dummy Stack API key

 //Obj-C
 Stack *stack = [Contentstack stackWithAPIKey:@"blt5d4sample2633b" accessToken:@"blt3esampletokeneb02" environmentName:@"dummy"];
 Asset *asset = [stack asset];
 [asset setHeader:@"MyValue" forKey:@"My-Custom-Header"];

 //Swift
  var stack:Stack = Contentstack.stackWithAPIKey("blt5d4sample2633b", accessToken:"blt3esampletokeneb02", environmentName:@"dummy")
  var asset:Asset = stack.asset()
  asset.setHeader("MyValue", forKey: "My-Custom-Header")

Declared In

Asset.h

– addHeadersWithDictionary:

Set a header for Asset

- (void)addHeadersWithDictionary:(NSDictionary *)headers

Parameters

headers

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

Discussion

  //'blt5d4sample2633b' is a dummy Stack API key

  //Obj-C
  Stack *stack = [Contentstack stackWithAPIKey:@"blt5d4sample2633b" accessToken:@"blt3esampletokeneb02" environmentName:@"dummy"];
  Asset *asset = [stack asset];
  [asset addHeadersWithDictionary:@{@"My-Custom-Header": @"MyValue"}];

  //Swift
  var stack:Stack = Contentstack.stackWithAPIKey("blt5d4sample2633b", accessToken:"blt3esampletokeneb02", environmentName:@"dummy")
  var asset:Asset = stack.asset()
  asset.addHeadersWithDictionary(["My-Custom-Header":"MyValue"])

Declared In

Asset.h

– addParamKey:andValue:

This method adds key and value to an Asset.

- (void)addParamKey:(NSString *)key andValue:(NSString *)value

Parameters

key

The key as string which needs to be added to an Asset

value

The value as string which needs to be added to an Asset

Discussion

 //'blt5d4sample2633b' is a dummy Stack API key

 //Obj-C
 Stack *stack = [Contentstack stackWithAPIKey:@"blt5d4sample2633b" accessToken:@"blt3esampletokeneb02" environmentName:@"dummy"];
 Asset *asset = [stack asset];
 [blogQuery addParamKey:@"key" andValue:@"value"];

 //Swift
 var stack:Stack = Contentstack.stackWithAPIKey("blt5d4sample2633b", accessToken:"blt3esampletokeneb02", environmentName:@"dummy")
 var asset:Asset = stack.asset()
 blogQuery.addParamKey("key", andValue:"value")

Declared In

Asset.h

– removeHeaderForKey:

Removes a header from this Asset

- (void)removeHeaderForKey:(NSString *)headerKey

Parameters

headerKey

The header key that needs to be removed

Discussion

 //'blt5d4sample2633b' is a dummy Stack API key

 //Obj-C
 Stack *stack = [Contentstack stackWithAPIKey:@"blt5d4sample2633b" accessToken:@"blt3esampletokeneb02" environmentName:@"dummy"];
 Asset *asset = [stack asset];
 [asset removeHeaderForKey:@"My-Custom-Header"];

 //Swift
 var stack:Stack = Contentstack.stackWithAPIKey("blt5d4sample2633b", accessToken:"blt3esampletokeneb02", environmentName:@"dummy")
 var asset:Asset = stack.asset()
 asset.removeHeaderForKey("My-Custom-Header")

Declared In

Asset.h

Fetch

– fetch:

Fetches an asset asynchronously provided asset UID

- (void)fetch:(void ( ^ ) ( ResponseType type , NSError *BUILT_NULLABLE_P error ))callback

Parameters

callback

Completion block with params NSError

Discussion

 //Obj-C
 Stack *stack = [Contentstack stackWithAPIKey:@"blt5d4sample2633b" accessToken:@"blt3esampletokeneb02" environmentName:@"dummy"];
 //'bltf4fsamplec857bk' is uid of an asset
 Asset* assetObj = [stack assetWithUID:@"bltf4fsamplec857bk"];
 [assetObj fetch:^(ResponseType type, NSError *error) {
    //error if exists then use 'error' object for details
 }];

 //Swift
 var stack:Stack = Contentstack.stackWithAPIKey("blt5d4sample2633b", accessToken:"blt3esampletokeneb02", environmentName:@"dummy")
 //'bltf4fsamplec857bk' is uid of an asset
 var assetObj:Asset = stack.assetWithUID("bltf4fsamplec857bk")
 assetObj.fetch { (responseType, error!) -> Void in
    //error if exists then use 'error' object for details
 }

Declared In

Asset.h