SCExtendedApiSession Class Reference
Inherits from | NSObject |
Declared in | SCExtendedApiSession.h |
Overview
The SCExtendedApiSession object provides support to perform the loading of system Items and their Fields from the backend.
All methods of this class can be divided into two general types.
asynchronous methods that load data from the backend. All such methods returns a block with SCExtendedAsyncOp type as a result.
synchronous “getters” methods. They are used for accessing loaded Items and Fields which are still in the memory cache.
SCExtendedApiSession object does not own loaded items and fields. However, they stay in memory cache as long as possible (until the memory warning occurs). You should keep a strong reference to the objects you need to make sure they survive the memory warning.
Items ( SCItem objects ) owns their descendant items and fields ( SCField objects ).
All methods of this class are not thread safe and they should be called exceptionally from one thread (main thread suggested).
Warning : We do not recommend creating SCExtendedApiSession directly. A primary approach is creatign an SCApiSession objet and access its [SCApiSession extendedApiSession] property.
Tasks
-
mainSession
An instance of the corresponding SCApiSession object that owns “self”.
property -
host
The host of Sitecore Item Web Api. For example, “http://mobilesdk.sc-demo.net:80”
property -
defaultSite
The site used to request Sitecore items, default is “nil”.
property -
defaultLanguage
The language used to request Sitecore items, default is “en”.
property -
defaultDatabase
The database used to request Sitecore items, default is “web”.
property -
defaultItemVersion
The version used to request Sitecore items, default is “nil” which means the latest version will be retrieved.
property -
mediaLibraryPath
Media library root folder in the content tree.
property
By default it is “/sitecore/media library”. -
+ defaultMediaLibraryPath
Default media library root folder in the content tree.
-
defaultLifeTimeInCache
The default life time in cache after which object in cache becames old. Default value is ten minutes
property -
defaultImagesLifeTimeInCache
The default life time in cache after which object in cache becames old. Default value is one monce
property -
systemLanguages
The Sitecore system languages, by default is nil.
property
To read Sitecore system languages call [SCApiSession readSystemLanguagesOperation] method. -
– cleanupItemsCache
This method wipes out all cached items. Cached requests won’t be affected though.
Use this method if you need to perform a memory intensive operation efficiently. It should help you avoiding unwanted memory warning interrupts. -
– checkCredentialsOperationForSite:
Used to check if a user with given name and password exists on the instance.
The callback gets NSNull on success and nil on error. -
– readSystemLanguagesOperation
Used to load Sitecore system languages from the backend.
-
– readItemsOperationWithRequest:
Used to load items from the backend according to the properties of SCReadItemsRequest object
-
– itemWithPath:itemSource:
Returns SCItem object with a given items’s path if such system item was loaded and still exists in the memory
-
– itemWithId:itemSource:
Returns SCItem object with a given items’s ID if such system item was loaded and still exists in the memory
-
– readItemOperationForItemId:itemSource:
Used to load item from the backend with a given system item ID
-
– readItemOperationForItemPath:itemSource:
Used for the reading item from a backend with a given system item path
-
– fieldWithName:itemId:itemSource:
Returns SCField object for the given items’s ID and field’s name if such field was loaded and the item has a field with such name
-
– readFieldsByNameForItemId:itemSource:
Returns loaded fields for the given item.
-
– readItemOperationForFieldsNames:itemId:itemSource:
Used to load item with fields by the system item id.
-
– readItemOperationForFieldsNames:itemPath:itemSource:
Used to load item with fields by the system item id.
-
– createItemsOperationWithRequest:
Used to create item according to the properties of SCCreateItemRequest object
-
– editItemsOperationWithRequest:
Used to edit existing items according to the properties of SCEditItemsRequest object
-
– deleteItemsOperationWithRequest:
Used to remove existing items found with SCReadItemsRequest request.
-
– uploadMediaOperationWithRequest:
Used to create media item according to the properties of SCUploadMediaItemRequest object
-
– readChildrenOperationForItemId:itemSource:
Used to load item’s children by the system item id.
-
– readChildrenOperationForItemPath:itemSource:
Used to load item’s children by the system item id.
-
– downloadResourceOperationForMediaPath:imageParams:
Used to load image with the image path, see [SCImageField imagePath] with additional parameters.
-
– getRenderingHtmlOperationWithRequest:
Used to request rendering HTML.
-
– getRenderingHtmlOperationForRenderingWithId:sourceId:
Used to request rendering HTML for Sitecore rendering with the specified id and item id. The default source of the SCApiSession is used to search for both the item and its rendering.
-
– triggerOperationWithRequest:
Used to trigger a goal or a campain with the given request
Properties
defaultDatabase
The database used to request Sitecore items, default is “web”.
@property (nonatomic) NSString *defaultDatabase
Discussion
The database used to request Sitecore items, default is “web”.
Declared In
SCExtendedApiSession.h
defaultImagesLifeTimeInCache
The default life time in cache after which object in cache becames old. Default value is one monce
@property (nonatomic) NSTimeInterval defaultImagesLifeTimeInCache
Discussion
The default life time in cache after which object in cache becames old. Default value is one monce
Declared In
SCExtendedApiSession.h
defaultItemVersion
The version used to request Sitecore items, default is “nil” which means the latest version will be retrieved.
@property (nonatomic) NSString *defaultItemVersion
Discussion
The version used to request Sitecore items, default is “nil” which means the latest version will be retrieved.
Declared In
SCExtendedApiSession.h
defaultLanguage
The language used to request Sitecore items, default is “en”.
@property (nonatomic) NSString *defaultLanguage
Discussion
The language used to request Sitecore items, default is “en”.
Declared In
SCExtendedApiSession.h
defaultLifeTimeInCache
The default life time in cache after which object in cache becames old. Default value is ten minutes
@property (nonatomic) NSTimeInterval defaultLifeTimeInCache
Discussion
The default life time in cache after which object in cache becames old. Default value is ten minutes
Declared In
SCExtendedApiSession.h
defaultSite
The site used to request Sitecore items, default is “nil”.
@property (nonatomic) NSString *defaultSite
Discussion
The site used to request Sitecore items, default is “nil”.
Declared In
SCExtendedApiSession.h
host
The host of Sitecore Item Web Api. For example, “http://mobilesdk.sc-demo.net:80”
@property (nonatomic, readonly) NSString *host
Discussion
The host of Sitecore Item Web Api. For example, “http://mobilesdk.sc-demo.net:80”
Declared In
SCExtendedApiSession.h
mainSession
An instance of the corresponding SCApiSession object that owns “self”.
@property (nonatomic, readonly, weak) SCApiSession *mainSession
Return Value
nil - if the object was created directly. The SCApiSession instance otherwise.
Discussion
An instance of the corresponding SCApiSession object that owns “self”.
Declared In
SCExtendedApiSession.h
mediaLibraryPath
Media library root folder in the content tree.
By default it is “/sitecore/media library”.
@property (nonatomic) NSString *mediaLibraryPath
Discussion
Media library root folder in the content tree.
By default it is “/sitecore/media library”.
Note : it must match the web.config settings on the back end.
Declared In
SCExtendedApiSession.h
systemLanguages
The Sitecore system languages, by default is nil.
To read Sitecore system languages call [SCApiSession readSystemLanguagesOperation] method.
@property (nonatomic) NSSet *systemLanguages
Discussion
The Sitecore system languages, by default is nil.
To read Sitecore system languages call [SCApiSession readSystemLanguagesOperation] method.
Declared In
SCExtendedApiSession.h
Instance Methods
checkCredentialsOperationForSite:
Used to check if a user with given name and password exists on the instance.
The callback gets NSNull on success and nil on error.
- (SCExtendedAsyncOp)checkCredentialsOperationForSite:(NSString *)site
Parameters
- site
name of the site, set up on the instance. Site name must start with a slash. For example, @“/sitecore/shell”. Pass “nil” for the default site.
Return Value
SCExtendedAsyncOp block. Call it to get the expected result.
Discussion
Used to check if a user with given name and password exists on the instance.
The callback gets NSNull on success and nil on error.
Declared In
SCExtendedApiSession.h
cleanupItemsCache
This method wipes out all cached items. Cached requests won’t be affected though.
Use this method if you need to perform a memory intensive operation efficiently. It should help you avoiding unwanted memory warning interrupts.
- (void)cleanupItemsCache
Discussion
This method wipes out all cached items. Cached requests won’t be affected though.
Use this method if you need to perform a memory intensive operation efficiently. It should help you avoiding unwanted memory warning interrupts.
Declared In
SCExtendedApiSession.h
createItemsOperationWithRequest:
Used to create item according to the properties of SCCreateItemRequest object
- (SCExtendedAsyncOp)createItemsOperationWithRequest:(SCCreateItemRequest *)createItemRequest
Parameters
- createItemRequest
SCCreateItemRequest object which provides a bunch of options to create item
Return Value
SCExtendedAsyncOp block. Call it to create item. The SCAsyncOpResult handler’s result is SCItem object or nil if error happens.
Discussion
Used to create item according to the properties of SCCreateItemRequest object
Declared In
SCExtendedApiSession.h
deleteItemsOperationWithRequest:
Used to remove existing items found with SCReadItemsRequest request.
- (SCExtendedAsyncOp)deleteItemsOperationWithRequest:(SCReadItemsRequest *)request
Parameters
- request
SCReadItemsRequest object which provides a bunch of options to find items to remove.
Return Value
SCExtendedAsyncOp block. Call it to edit items. The SCAsyncOpResult handler’s result is NSArray of removed items ids or nil if error happens.
Discussion
Used to remove existing items found with SCReadItemsRequest request.
Declared In
SCExtendedApiSession.h
downloadResourceOperationForMediaPath:imageParams:
Used to load image with the image path, see [SCImageField imagePath] with additional parameters.
- (SCExtendedAsyncOp)downloadResourceOperationForMediaPath:(NSString *)path imageParams:(SCDownloadMediaOptions *)params
Parameters
- path
image’s path. Image with http://{WebApiHost}/~/media{path}.ashx will be loaded.
- params
Options for image processing on the server side before downloading. The most frequent use case is resizing images. For more details see SCDownloadMediaOptions class.
Return Value
SCExtendedAsyncOp block. Call it to get the expected result. The SCAsyncOpResult handler’s result is UIImage object or nil if error happens.
Discussion
Used to load image with the image path, see [SCImageField imagePath] with additional parameters.
Declared In
SCExtendedApiSession.h
editItemsOperationWithRequest:
Used to edit existing items according to the properties of SCEditItemsRequest object
- (SCExtendedAsyncOp)editItemsOperationWithRequest:(SCEditItemsRequest *)editItemsRequest
Parameters
- editItemsRequest
SCEditItemsRequest object which provides a bunch of options to edit items
Return Value
SCExtendedAsyncOp block. Call it to edit items. The SCAsyncOpResult handler’s result is NSArray of edited SCItem objects or nil if error happens.
Discussion
Used to edit existing items according to the properties of SCEditItemsRequest object
Declared In
SCExtendedApiSession.h
fieldWithName:itemId:itemSource:
Returns SCField object for the given items’s ID and field’s name if such field was loaded and the item has a field with such name
- (SCField *)fieldWithName:(NSString *)fieldName itemId:(NSString *)itemId itemSource:(id<SCItemSource>)itemSource
Parameters
- fieldName
the name of item’s field name, see [SCField name]
- itemId
system item’s id, [SCItem itemId] can be used.
- itemSource
source of the item. This is a place to specify a database, a site, etc.
Return Value
SCField object or nil if such field does not exists.
Discussion
Returns SCField object for the given items’s ID and field’s name if such field was loaded and the item has a field with such name
Declared In
SCExtendedApiSession.h
getRenderingHtmlOperationForRenderingWithId:sourceId:
Used to request rendering HTML for Sitecore rendering with the specified id and item id. The default source of the SCApiSession is used to search for both the item and its rendering.
- (SCExtendedAsyncOp)getRenderingHtmlOperationForRenderingWithId:(NSString *)renderingId sourceId:(NSString *)sourceId
Parameters
- renderingId
- id of rendering which you want to request
- sourceId
- item’s id for render using rendering with renderingId
Return Value
SCExtendedAsyncOp block. Call it to get the expected result. The SCAsyncOpResult handler’s result is NSString object or nil if error happens.
Discussion
Used to request rendering HTML for Sitecore rendering with the specified id and item id. The default source of the SCApiSession is used to search for both the item and its rendering.
Declared In
SCExtendedApiSession.h
getRenderingHtmlOperationWithRequest:
Used to request rendering HTML.
- (SCExtendedAsyncOp)getRenderingHtmlOperationWithRequest:(SCGetRenderingHtmlRequest *)request
Parameters
- request
contains the information about
- rendering item id
- rendering datasource item id
- source of both the rendering and the datasource. See SCItemSource protocol for more details
Return Value
SCExtendedAsyncOp block. Call it to get the expected result. The SCAsyncOpResult handler’s result is NSString object or nil if error happens.
Discussion
Used to request rendering HTML.
Declared In
SCExtendedApiSession.h
itemWithId:itemSource:
Returns SCItem object with a given items’s ID if such system item was loaded and still exists in the memory
- (SCItem *)itemWithId:(NSString *)itemId itemSource:(id<SCItemSource>)itemSource
Parameters
- itemId
system item’s id, [SCItem itemId] can be used.
- itemSource
source of the item. This is a place to specify a database, a site, etc.
Return Value
SCItem object or nil if such item does not exists.
Discussion
Returns SCItem object with a given items’s ID if such system item was loaded and still exists in the memory
Declared In
SCExtendedApiSession.h
itemWithPath:itemSource:
Returns SCItem object with a given items’s path if such system item was loaded and still exists in the memory
- (SCItem *)itemWithPath:(NSString *)path itemSource:(id<SCItemSource>)itemSource
Parameters
- path
system item’s path, [SCItem path] or string (for example “/sitecore/content”).
- itemSource
source of the item. This is a place to specify a database, a site, etc.
Return Value
SCItem object or nil if such item does not exists.
Discussion
Returns SCItem object with a given items’s path if such system item was loaded and still exists in the memory
Declared In
SCExtendedApiSession.h
readChildrenOperationForItemId:itemSource:
Used to load item’s children by the system item id.
- (SCExtendedAsyncOp)readChildrenOperationForItemId:(NSString *)itemId itemSource:(id<SCItemSource>)itemSource
Parameters
- itemId
system item’s id, [SCItem itemId] can be used.
- itemSource
source of the item. This is a place to specify a database, a site, etc.
Return Value
SCExtendedAsyncOp block. Call it to get the expected result. The SCAsyncOpResult handler’s result is NSArray of SCItem objects or nil if error happens.
Discussion
Used to load item’s children by the system item id.
Declared In
SCExtendedApiSession.h
readChildrenOperationForItemPath:itemSource:
Used to load item’s children by the system item id.
- (SCExtendedAsyncOp)readChildrenOperationForItemPath:(NSString *)path itemSource:(id<SCItemSource>)itemSource
Parameters
- path
system item’s path, [SCItem path] or string (for example “/sitecore/content”).
- itemSource
source of the item. This is a place to specify a database, a site, etc.
Return Value
SCExtendedAsyncOp block. Call it to get the expected result. The SCAsyncOpResult handler’s result is NSArray of SCItem objects or nil if error happens.
SCAsyncOpResult handler may return such errors:
SCInvalidPathError - invalid path argument was passed.
SCNetworkError - if network error happens.
SCInvalidResponseFormatError - response can not be processed
Discussion
Used to load item’s children by the system item id.
Declared In
SCExtendedApiSession.h
readFieldsByNameForItemId:itemSource:
Returns loaded fields for the given item.
- (NSDictionary *)readFieldsByNameForItemId:(NSString *)itemId itemSource:(id<SCItemSource>)itemSource
Parameters
- itemId
system item’s id, [SCItem itemId] can be used.
- itemSource
source of the item. This is a place to specify a database, a site, etc.
Return Value
loaded fields for the given item. It is a NSDictionary of SCField objects by field’s names.
Discussion
Returns loaded fields for the given item.
Declared In
SCExtendedApiSession.h
readItemOperationForFieldsNames:itemId:itemSource:
Used to load item with fields by the system item id.
- (SCExtendedAsyncOp)readItemOperationForFieldsNames:(NSSet *)fieldNames itemId:(NSString *)itemId itemSource:(id<SCItemSource>)itemSource
Parameters
- fieldNames
the set of field’s names which will be read with the item. Each field’s name in set should be a string.
For reading all fields - pass nil or pass empty set if you don’t need to read any field
- itemId
system item’s id, [SCItem itemId] can be used.
- itemSource
source of the item. This is a place to specify a database, a site, etc.
Return Value
SCExtendedAsyncOp block. Call it to get the expected result. The SCAsyncOpResult handler’s result is SCItem object or nil if error happens.
SCAsyncOpResult handler may return such errors:
SCNoItemError - if Sitecore Item Web Api(backend) does not return any item.
SCNetworkError - if network error happens.
SCInvalidResponseFormatError - response can not be processed
Discussion
Used to load item with fields by the system item id.
Declared In
SCExtendedApiSession.h
readItemOperationForFieldsNames:itemPath:itemSource:
Used to load item with fields by the system item id.
- (SCExtendedAsyncOp)readItemOperationForFieldsNames:(NSSet *)fieldNames itemPath:(NSString *)path itemSource:(id<SCItemSource>)itemSource
Parameters
- fieldNames
the set of field’s names which will be read with the item. Each field’s name in set should be a string.
For reading all fields - pass nil or pass empty set if you don’t need to read any field
- path
system item’s path, [SCItem path] or string (for example “/sitecore/content”).
- itemSource
source of the item. This is a place to specify a database, a site, etc.
Return Value
SCExtendedAsyncOp block. Call it to get the expected result. The SCAsyncOpResult handler’s result is SCItem object or nil if error happens.
SCAsyncOpResult handler may return such errors:
SCNoItemError - if Sitecore Item Web Api(backend) does not return any item.
SCInvalidPathError - invalid path argument was passed.
SCNetworkError - if network error happens.
SCInvalidResponseFormatError - response can not be processed
Discussion
Used to load item with fields by the system item id.
Declared In
SCExtendedApiSession.h
readItemOperationForItemId:itemSource:
Used to load item from the backend with a given system item ID
- (SCExtendedAsyncOp)readItemOperationForItemId:(NSString *)itemId itemSource:(id<SCItemSource>)itemSource
Parameters
- itemId
system item’s id, [SCItem itemId] can be used.
- itemSource
source of the item. This is a place to specify a database, a site, etc.
Return Value
SCExtendedAsyncOp block. Call it to get the expected result. The SCAsyncOpResult handler’s result is SCItem object or nil if error happens.
If Sitecore Item Web Api(backend) does not return any item, SCNoItemError error will be returned by SCAsyncOpResult handler.
Discussion
Used to load item from the backend with a given system item ID
Declared In
SCExtendedApiSession.h
readItemOperationForItemPath:itemSource:
Used for the reading item from a backend with a given system item path
- (SCExtendedAsyncOp)readItemOperationForItemPath:(NSString *)path itemSource:(id<SCItemSource>)itemSource
Parameters
- path
system item’s path, [SCItem path] or string (for example “/sitecore/content”).
- itemSource
source of the item. This is a place to specify a database, a site, etc.
Return Value
SCExtendedAsyncOp block. Call it to get the expected result. The SCAsyncOpResult handler’s result is SCItem object or nil if error happens.
SCAsyncOpResult handler may return such errors:
SCNoItemError - if Sitecore Item Web Api(backend) does not return any item.
SCInvalidPathError - invalid path argument was passed.
SCNetworkError - network error happens.
SCInvalidResponseFormatError - response can not be processed
Discussion
Used for the reading item from a backend with a given system item path
Declared In
SCExtendedApiSession.h
readItemsOperationWithRequest:
Used to load items from the backend according to the properties of SCReadItemsRequest object
- (SCExtendedAsyncOp)readItemsOperationWithRequest:(SCReadItemsRequest *)request
Parameters
- request
SCReadItemsRequest object which provides a bunch of options to load items from the backend or getting already loaded items
Return Value
SCExtendedAsyncOp block. Call it to get the expected result. The SCAsyncOpResult handler’s result is NSArray of SCItem objects or nil if error happens.
Discussion
Used to load items from the backend according to the properties of SCReadItemsRequest object
Declared In
SCExtendedApiSession.h
readSystemLanguagesOperation
Used to load Sitecore system languages from the backend.
- (SCExtendedAsyncOp)readSystemLanguagesOperation
Return Value
SCExtendedAsyncOp block. Call it to get the expected result. The SCAsyncOpResult handler’s result is NSSet of strings or nil if error happens.
Discussion
Used to load Sitecore system languages from the backend.
Declared In
SCExtendedApiSession.h
triggerOperationWithRequest:
Used to trigger a goal or a campain with the given request
- (SCExtendedAsyncOp)triggerOperationWithRequest:(SCTriggeringRequest *)request
Parameters
- request
A triggering request. See SCTrafficTriggeringRequest and SCCampaignTriggeringRequest for details
Return Value
SCExtendedAsyncOp block. Call it to trigger either a goal or a campaign. The SCAsyncOpResult handler’s result is an NSString that contains the rendering of the item (an HTML web page).
Discussion
Used to trigger a goal or a campain with the given request
Declared In
SCExtendedApiSession.h
uploadMediaOperationWithRequest:
Used to create media item according to the properties of SCUploadMediaItemRequest object
- (SCExtendedAsyncOp)uploadMediaOperationWithRequest:(SCUploadMediaItemRequest *)createMediaItemRequest
Parameters
- createMediaItemRequest
SCUploadMediaItemRequest object which provides a bunch of options to create media item
Return Value
SCExtendedAsyncOp block. Call it to create media item. The SCAsyncOpResult handler’s result is SCItem object or nil if error happens.
Discussion
Used to create media item according to the properties of SCUploadMediaItemRequest object
Declared In
SCExtendedApiSession.h