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
-
mainSessionAn instance of the corresponding SCApiSession object that owns “self”.
property -
hostThe host of Sitecore Item Web Api. For example, “http://mobilesdk.sc-demo.net:80”
property -
defaultSiteThe site used to request Sitecore items, default is “nil”.
property -
defaultLanguageThe language used to request Sitecore items, default is “en”.
property -
defaultDatabaseThe database used to request Sitecore items, default is “web”.
property -
defaultItemVersionThe version used to request Sitecore items, default is “nil” which means the latest version will be retrieved.
property -
mediaLibraryPathMedia library root folder in the content tree.
property
By default it is “/sitecore/media library”. -
+ defaultMediaLibraryPathDefault media library root folder in the content tree.
-
defaultLifeTimeInCacheThe default life time in cache after which object in cache becames old. Default value is ten minutes
property -
defaultImagesLifeTimeInCacheThe default life time in cache after which object in cache becames old. Default value is one monce
property -
systemLanguagesThe Sitecore system languages, by default is nil.
property
To read Sitecore system languages call [SCApiSession readSystemLanguagesOperation] method. -
– cleanupItemsCacheThis 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. -
– readSystemLanguagesOperationUsed 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 *defaultDatabaseDiscussion
The database used to request Sitecore items, default is “web”.
Declared In
SCExtendedApiSession.hdefaultImagesLifeTimeInCache
The default life time in cache after which object in cache becames old. Default value is one monce
@property (nonatomic) NSTimeInterval defaultImagesLifeTimeInCacheDiscussion
The default life time in cache after which object in cache becames old. Default value is one monce
Declared In
SCExtendedApiSession.hdefaultItemVersion
The version used to request Sitecore items, default is “nil” which means the latest version will be retrieved.
@property (nonatomic) NSString *defaultItemVersionDiscussion
The version used to request Sitecore items, default is “nil” which means the latest version will be retrieved.
Declared In
SCExtendedApiSession.hdefaultLanguage
The language used to request Sitecore items, default is “en”.
@property (nonatomic) NSString *defaultLanguageDiscussion
The language used to request Sitecore items, default is “en”.
Declared In
SCExtendedApiSession.hdefaultLifeTimeInCache
The default life time in cache after which object in cache becames old. Default value is ten minutes
@property (nonatomic) NSTimeInterval defaultLifeTimeInCacheDiscussion
The default life time in cache after which object in cache becames old. Default value is ten minutes
Declared In
SCExtendedApiSession.hdefaultSite
The site used to request Sitecore items, default is “nil”.
@property (nonatomic) NSString *defaultSiteDiscussion
The site used to request Sitecore items, default is “nil”.
Declared In
SCExtendedApiSession.hhost
The host of Sitecore Item Web Api. For example, “http://mobilesdk.sc-demo.net:80”
@property (nonatomic, readonly) NSString *hostDiscussion
The host of Sitecore Item Web Api. For example, “http://mobilesdk.sc-demo.net:80”
Declared In
SCExtendedApiSession.hmainSession
An instance of the corresponding SCApiSession object that owns “self”.
@property (nonatomic, readonly, weak) SCApiSession *mainSessionReturn 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.hmediaLibraryPath
Media library root folder in the content tree.
By default it is “/sitecore/media library”.
@property (nonatomic) NSString *mediaLibraryPathDiscussion
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.hsystemLanguages
The Sitecore system languages, by default is nil.
To read Sitecore system languages call [SCApiSession readSystemLanguagesOperation] method.
@property (nonatomic) NSSet *systemLanguagesDiscussion
The Sitecore system languages, by default is nil.
To read Sitecore system languages call [SCApiSession readSystemLanguagesOperation] method.
Declared In
SCExtendedApiSession.hInstance 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 *)siteParameters
- 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.hcleanupItemsCache
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)cleanupItemsCacheDiscussion
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.hcreateItemsOperationWithRequest:
Used to create item according to the properties of SCCreateItemRequest object
- (SCExtendedAsyncOp)createItemsOperationWithRequest:(SCCreateItemRequest *)createItemRequestParameters
- 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.hdeleteItemsOperationWithRequest:
Used to remove existing items found with SCReadItemsRequest request.
- (SCExtendedAsyncOp)deleteItemsOperationWithRequest:(SCReadItemsRequest *)requestParameters
- 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.hdownloadResourceOperationForMediaPath:imageParams:
Used to load image with the image path, see [SCImageField imagePath] with additional parameters.
- (SCExtendedAsyncOp)downloadResourceOperationForMediaPath:(NSString *)path imageParams:(SCDownloadMediaOptions *)paramsParameters
- 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.heditItemsOperationWithRequest:
Used to edit existing items according to the properties of SCEditItemsRequest object
- (SCExtendedAsyncOp)editItemsOperationWithRequest:(SCEditItemsRequest *)editItemsRequestParameters
- 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.hfieldWithName: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>)itemSourceParameters
- 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.hgetRenderingHtmlOperationForRenderingWithId: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 *)sourceIdParameters
- 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.hgetRenderingHtmlOperationWithRequest:
Used to request rendering HTML.
- (SCExtendedAsyncOp)getRenderingHtmlOperationWithRequest:(SCGetRenderingHtmlRequest *)requestParameters
- 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.hitemWithId: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>)itemSourceParameters
- 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.hitemWithPath: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>)itemSourceParameters
- 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.hreadChildrenOperationForItemId:itemSource:
Used to load item’s children by the system item id.
- (SCExtendedAsyncOp)readChildrenOperationForItemId:(NSString *)itemId itemSource:(id<SCItemSource>)itemSourceParameters
- 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.hreadChildrenOperationForItemPath:itemSource:
Used to load item’s children by the system item id.
- (SCExtendedAsyncOp)readChildrenOperationForItemPath:(NSString *)path itemSource:(id<SCItemSource>)itemSourceParameters
- 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.hreadFieldsByNameForItemId:itemSource:
Returns loaded fields for the given item.
- (NSDictionary *)readFieldsByNameForItemId:(NSString *)itemId itemSource:(id<SCItemSource>)itemSourceParameters
- 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.hreadItemOperationForFieldsNames:itemId:itemSource:
Used to load item with fields by the system item id.
- (SCExtendedAsyncOp)readItemOperationForFieldsNames:(NSSet *)fieldNames itemId:(NSString *)itemId itemSource:(id<SCItemSource>)itemSourceParameters
- 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.hreadItemOperationForFieldsNames:itemPath:itemSource:
Used to load item with fields by the system item id.
- (SCExtendedAsyncOp)readItemOperationForFieldsNames:(NSSet *)fieldNames itemPath:(NSString *)path itemSource:(id<SCItemSource>)itemSourceParameters
- 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.hreadItemOperationForItemId:itemSource:
Used to load item from the backend with a given system item ID
- (SCExtendedAsyncOp)readItemOperationForItemId:(NSString *)itemId itemSource:(id<SCItemSource>)itemSourceParameters
- 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.hreadItemOperationForItemPath:itemSource:
Used for the reading item from a backend with a given system item path
- (SCExtendedAsyncOp)readItemOperationForItemPath:(NSString *)path itemSource:(id<SCItemSource>)itemSourceParameters
- 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.hreadItemsOperationWithRequest:
Used to load items from the backend according to the properties of SCReadItemsRequest object
- (SCExtendedAsyncOp)readItemsOperationWithRequest:(SCReadItemsRequest *)requestParameters
- 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.hreadSystemLanguagesOperation
Used to load Sitecore system languages from the backend.
- (SCExtendedAsyncOp)readSystemLanguagesOperationReturn 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.htriggerOperationWithRequest:
Used to trigger a goal or a campain with the given request
- (SCExtendedAsyncOp)triggerOperationWithRequest:(SCTriggeringRequest *)requestParameters
- 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.huploadMediaOperationWithRequest:
Used to create media item according to the properties of SCUploadMediaItemRequest object
- (SCExtendedAsyncOp)uploadMediaOperationWithRequest:(SCUploadMediaItemRequest *)createMediaItemRequestParameters
- 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