ArcGIS Runtime SDK for iOS: AGSPortalItem Class Reference
ArcGIS Runtime SDK for iOS  100.15
AGSPortalItem Class Reference

Description

Object representing a unit of content in an ArcGIS portal.

An AGSPortalItem is a unit of content in the AGSPortal object. Each item has a unique identifier and a well- known URL that is independent of the user owning the item. An item may have associated binary or textual data which has to be fetched explicitly using fetchDataWithCompletion: (AGSItem). For example, an item of type AGSPortalItemTypeMapPackage will fetch the actual bits corresponding to the map package.

Since
100
Inheritance diagram for AGSPortalItem:
AGSItem <AGSLoadable> <AGSJSONSerializable> AGSObject

Instance Methods

(id< AGSCancelable >) - addComment:completion:
 
(id< AGSCancelable >) - addRating:completion:
 
(void) - cancelLoad
 
(id< AGSCancelable >) - fetchCommentsWithCompletion:
 
(id< AGSCancelable >) - fetchDataWithCompletion:
 
(id< AGSCancelable >) - fetchGroupsWithCompletion:
 
(id< AGSCancelable >) - fetchRelatedItemsWithRelationship:direction:completion:
 
(id< AGSCancelable >) - fetchRelatedItemsWithRelationships:direction:completion:
 
(instancetype) - initWithPortal:
 
(instancetype) - initWithPortal:itemID:
 
(instancetype) - initWithPortal:type:
 
(nullable instancetype) - initWithURL:
 
(void) - loadWithCompletion:
 
(void) - retryLoadWithCompletion:
 
(void) - setThumbnailWithImage:
 
(id< AGSCancelable >) - shareWithEveryone:org:completion:
 
(id< AGSCancelable >) - shareWithGroups:completion:
 
(__nullable id) - toJSON:
 
(id< AGSCancelable >) - unshareWithCompletion:
 
(id< AGSCancelable >) - unshareWithGroups:completion:
 
(id< AGSCancelable >) - updateData:completion:
 
(id< AGSCancelable >) - updateDataWithJSON:completion:
 
(id< AGSCancelable >) - updateItemPropertiesWithCompletion:
 

Class Methods

(nullable id< AGSJSONSerializable >) + fromJSON:error:
 
(nullable AGSPortalItem *) + fromJSON:withPortal:error:
 
(instancetype) + portalItemWithPortal:
 
(instancetype) + portalItemWithPortal:itemID:
 
(instancetype) + portalItemWithPortal:type:
 
(nullable instancetype) + portalItemWithURL:
 

Properties

NSString *GUID __deprecated
 
AGSPortalAccess access
 
NSString * accessAndUseConstraintsHtml
 
NSString * accessInformation
 
NSArray< AGSPortalGroup * > * adminGroups
 
CGFloat averageRating
 
NSInteger commentCount
 
NSArray< AGSPortalItemComment * > * comments
 
BOOL commentsEnabled
 
NSDate * created
 
AGSEnvelopeextent
 
NSString * folderID
 
NSString * itemDescription
 
NSString * itemID
 
NSError * loadError
 
AGSLoadStatus loadStatus
 
NSLocale * locale
 
NSArray< AGSPortalGroup * > * memberGroups
 
NSDate * modified
 
NSString * name
 
NSArray< AGSPortalGroup * > * otherGroups
 
NSString * owner
 
AGSPortalportal
 
NSInteger ratingCount
 
NSURL * serviceURL
 
long long size
 
NSString * snippet
 
NSString * spatialReferenceName
 
NSArray< NSString * > * tags
 
NSString * termsOfUse
 
AGSLoadableImagethumbnail
 
NSString * title
 
AGSPortalItemType type
 
NSArray< NSString * > * typeKeywords
 
NSString * typeName
 
NSDictionary< NSString *, id > * unknownJSON
 
NSDictionary< NSString *, id > * unsupportedJSON
 
AGSLoadableValueuserRating
 
NSInteger viewCount
 

Method Documentation

◆ addComment:completion:

- (id<AGSCancelable>) addComment: (NSString *)  comment
completion: (nullable void(^)(AGSPortalItemComment *__nullable resultComment, NSError *__nullable error))  completion 

Kicks off an operation to add a comment to an item. Available only to authenticated users who have access to the item. The completion block is invoked when the operation completes successfully or if an error is encountered.

Parameters
commentThe comment to add to the portal item.
completionA block that is invoked when operation finishes.
Returns
An operation which can be canceled.
Since
100

◆ addRating:completion:

- (id<AGSCancelable>) addRating: (CGFloat)  rating
completion: (nullable void(^)(NSError *__nullable error))  completion 

Kicks off an operation to add a rating to an item that the current portal user has access to. The completion block is invoked when the operation completes successfully or if an error is encountered. Upon success, the #avgRating and #numRatings will be updated on the portal item.

If the current user's rating has not been fetched, this method will fetch it before adding the rating. Only 1 rating can be given to an item per user. If this call is made on an already rated item, the new rating will overwrite the current one. A user cannot rate their own item. Available only to authenticated users.

Parameters
ratingThe rating to add to the portal item. The value must be between 1.0 and 5.0.
completionA block that is invoked when operation finishes.
Returns
An operation which can be canceled.
Since
100

◆ cancelLoad

- (void) cancelLoad
requiredinherited

Cancels loading if it is in progress, otherwise it does nothing. This should be called carefully because other objects could be waiting for loadWithCompletion: or retryLoadWithCompletion: to complete and this will call them all back with the error of NSUserCancelledError

Since
100

◆ fetchCommentsWithCompletion:

- (id<AGSCancelable>) fetchCommentsWithCompletion: (nullable void(^)(NSArray< AGSPortalItemComment * > *__nullable comments, NSError *__nullable error))  completion

Kicks off an operation to fetch user comments (AGSPortalItemComment objects) for the item. The completion block is invoked when the operation completes successfully or if an error is encountered. Once completed the comments property will be populated.

Parameters
completionblock that is invoked when operation finishes.
Returns
An operation which can be canceled.
Since
100

◆ fetchDataWithCompletion:

- (id<AGSCancelable>) fetchDataWithCompletion: (void(^)(NSData *__nullable data, NSError *__nullable error))  completion

Kicks off an operation to fetch the raw bytes for the item. The completion block is invoked when the operation completes successfully or if an error is encountered.

Parameters
completionblock that is invoked when operation finishes
Returns
operation which can be canceled
Since
100

◆ fetchGroupsWithCompletion:

- (id<AGSCancelable>) fetchGroupsWithCompletion: (nullable void(^)(NSArray< AGSPortalGroup * > *__nullable adminGroups, NSArray< AGSPortalGroup * > *__nullable memberGroups, NSArray< AGSPortalGroup * > *__nullable otherGroups, NSError *__nullable error))  completion

Kicks off an operation to fetch the groups (AGSPortalGroup objects) that this item belongs to. The completion block is invoked when the operation completes successfully or if an error is encountered. Only those groups that are visible to the current portal user will be returned. Once completed the adminGroups, memberGroups and, otherGroups properties will be populated.

Parameters
completionA block that is invoked when operation finishes with details about adminGroups, memberGroups, otherGroups that this item belongs to.
Returns
An operation which can be canceled.
Since
100

◆ fetchRelatedItemsWithRelationship:direction:completion:

- (id<AGSCancelable>) fetchRelatedItemsWithRelationship: (AGSPortalItemRelationship relationship
direction: (AGSPortalItemRelationshipDirection direction
completion: (void(^)(NSArray< AGSPortalItem * > *__nullable result, NSError *__nullable error))  completion 

Fetches all related portal items with the specified relationship to this portal item.

Parameters
relationshipThe relationship.
directionThe direction of the relationship.
completionA block that is invoked when the operation finishes. The result parameter is populated if the operation completed successfully, otherwise the error parameter is populated.
Returns
An operation which can be canceled.
Since
100.11

◆ fetchRelatedItemsWithRelationships:direction:completion:

- (id<AGSCancelable>) fetchRelatedItemsWithRelationships: (NSArray< NSValue * > *)  relationships
direction: (AGSPortalItemRelationshipDirection direction
completion: (void(^)(NSArray< AGSPortalItem * > *__nullable result, NSError *__nullable error))  completion 

Fetches all related portal items with any of the specified relationships to this portal item.

Parameters
relationshipsAn array of relationships.
directionThe direction of the relationships.
completionA block that is invoked when the operation finishes. The result parameter is populated if the operation completed successfully, otherwise the error parameter is populated.
Returns
An operation which can be canceled.
Since
100.11

◆ fromJSON:error:

+ (nullable id<AGSJSONSerializable>) fromJSON: (id)  JSONObject
error: (NSError **)  error 
staticrequiredinherited

Initializes and returns an object from its JSON representation.

Parameters
JSONObjectNSDictionary or NSArray containing the JSON.
errorencountered during the operation, if any.
Since
100

◆ fromJSON:withPortal:error:

+ (nullable AGSPortalItem *) fromJSON: (id)  JSONObject
withPortal: (AGSPortal *)  portal
error: (NSError **)  error 

Creates a portal item with JSON content to represent an existing item in the portal.

Parameters
JSONObjectRepresenting the JSON content of the item.
portalThe portal to which the item belongs to.
Since
100

◆ initWithPortal:

- (instancetype) initWithPortal: (AGSPortal *)  portal

Creates a new portal item object for a specified portal. This constructor is used if you wish to create a new item that you will add to a portal.

Parameters
portalThe portal.
See also
AGSPortalItem::portal
Since
100.0
Deprecated:
100.6.0. Use initWithPortal:type: instead.

Provided by category AGSPortalItem(AGSDeprecated).

◆ initWithPortal:itemID:

- (instancetype) initWithPortal: (AGSPortal *)  portal
itemID: (NSString *)  itemID 

Creates a portal item object for a specified portal and a specified item ID. Use this initializer to instantiate an AGSPortalItem object from an existing item using its unique ID. The portal item ID can be determined from the URL of the item details web page or the map viewer and scene viewer web applications in your portal. The item details page has the following format https://www.arcgis.com/home/item.html?id=[item_id]. The map viewer has the format https://www.arcgis.com/home/webmap/viewer.html?webmap=[item_id] or https://www.arcgis.com/apps/mapviewer/index.html?webmap=[item_id] depending on whether you use the classic map viewer or the new map viewer. The scene viewer has the following format https://www.arcgis.com/home/webscene/viewer.html?webscene=[item_id]. In all cases, the [item_id] can be used as the ID to instantiate a portal item.

Parameters
portalThe portal to which the item belongs to.
itemIDThe ID of the existing item in the portal.
Since
100

◆ initWithPortal:type:

- (instancetype) initWithPortal: (AGSPortal *)  portal
type: (AGSPortalItemType type 

Creates a new portal item object with the specified type for a specified portal. This initializer is used if you wish to create a new item that you will add to a portal.

Parameters
portalThe portal.
typeThe type of the new portal item.
See also
AGSPortalItem::portal, @C AGSPortalItem::type
Since
100.6

◆ initWithURL:

- (nullable instancetype) initWithURL: (NSURL *)  URL

Creates a portal item based on the given URL.

The supported URL formats are:

◆ loadWithCompletion:

- (void) loadWithCompletion: (nullable void(^)(NSError *__nullable error))  completion
requiredinherited

Loads data for the object asynchronously. The completion block is invoked upon completion.

You can call this method any number of times, however only one attempt is made to load the data. If it is already loading, it will just continue to load (i.e. not force a reload). If it has already loaded successfully, the completion block will be invoked right away. If it has already failed to load, the completion block will be invoked right away with error previously encountered. This method supports multiple callers and will call them all back on completion. However, each caller's completion block will be invoked once and only once.

Parameters
completionblock that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load.
Note
The completion block is always invoked on the main thread.
Since
100
See also
- cancelLoad to cancel loading
- retryLoadWithCompletion: to force reload

◆ portalItemWithPortal:

+ (instancetype) portalItemWithPortal: (AGSPortal *)  portal

Creates a new portal item object for a specified portal. This constructor is used if you wish to create a new item that you will add to a portal.

Parameters
portalThe portal.
See also
AGSPortalItem::portal
Since
100.0
Deprecated:
100.6.0. Use initWithPortal:type: instead.

Provided by category AGSPortalItem(AGSDeprecated).

◆ portalItemWithPortal:itemID:

+ (instancetype) portalItemWithPortal: (AGSPortal *)  portal
itemID: (NSString *)  itemID 

Creates a portal item object for a specified portal and a specified item ID. The portal item ID can be determined from the URL of the item details web page or the map viewer and scene viewer web applications in your portal. The item details page has the following format https://www.arcgis.com/home/item.html?id=[item_id]. The map viewer has the format https://www.arcgis.com/home/webmap/viewer.html?webmap=[item_id] or https://www.arcgis.com/apps/mapviewer/index.html?webmap=[item_id] depending on whether you use the classic map viewer or the new map viewer. The scene viewer has the following format https://www.arcgis.com/home/webscene/viewer.html?webscene=[item_id]. In all cases, the [item_id] can be used as the ID to instantiate a portal item.

Parameters
portalThe portal to which the item belongs to.
itemIDThe ID of the existing item in the portal.
Returns
A new portal item.
Since
100

◆ portalItemWithPortal:type:

+ (instancetype) portalItemWithPortal: (AGSPortal *)  portal
type: (AGSPortalItemType type 

Creates a portal item object with the specified type for a specified portal. This method is used if you wish to create a new item that you will add to a portal.

Parameters
portalThe portal.
typeThe type of the new portal item.
Returns
A new portal item.
See also
AGSPortalItem::portal, @C AGSPortalItem::type
Since
100.6

◆ portalItemWithURL:

+ (nullable instancetype) portalItemWithURL: (NSURL *)  URL

Creates a portal item based on the given URL.

The supported URL formats are:

◆ retryLoadWithCompletion:

- (void) retryLoadWithCompletion: (nullable void(^)(NSError *__nullable error))  completion
requiredinherited

Tries to reload when an object has failed to load. This method should be called judiciously. It should be called when:

  1. you didn't have network connectivity earlier when it failed and you want to retry now that you have connectivity
  2. the server was down earlier when it failed and you want to retry
  3. the request is taking too long and you want to cancel it and retry, in which case you will first call cancelLoad and then this method

If the data hasn't started loading, it will start loading. If it is already loading, it will just continue to load. If it has already loaded successfully, calls back right away. If it has already failed to load, tries again. This method supports multiple callers and will call them all back on completion. However, each caller's completion block will be invoked once and only once.

Parameters
completionblock that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load.
Note
The completion block is always invoked on the main thread.
Since
100

◆ setThumbnailWithImage:

- (void) setThumbnailWithImage: (nullable AGSImage *)  image

Sets the thumbnail for this item.

Parameters
imageThe NSImage/UIImage representing the thumbnail. The recommended image size is 200 pixels wide by 133 pixels high. Acceptable image formats are PNG, GIF, and JPEG. The maximum file size for an image is 1 MB.
Since
100

◆ toJSON:

- (__nullable id) toJSON: (NSError **)  error

Returns JSON representation for this object.

Returns
NSDictionary or NSArray containing the JSON.
Since
100

Reimplemented from <AGSJSONSerializable>.

Property Documentation

◆ __deprecated

- (NSString* GUID) __deprecated
readnonatomiccopy

The GUID of this portal item.

Since
100
Deprecated:
100.5 No replacement because this property is not useful. AGSItem.itemID provides a unique identifier of the item.

Provided by category AGSPortalItem(AGSDeprecated).

◆ access

- (AGSPortalAccess) access
readnonatomicassign

Indicates who can access this item. Can be AGSPortalAccessPrivate, AGSPortalAccessShared, AGSPortalAccessOrganization, or AGSPortalAccessPublic.

If AGSPortalAccessPrivate, only the item owner can access. AGSPortalAccessShared allows access to members of a group that the item is shared with. AGSPortalAccessOrganization restricts item access to members of an organization. If AGSPortalAccessPublic, all users can access the item.

Since
100

◆ accessAndUseConstraintsHtml

- (NSString*) accessAndUseConstraintsHtml
readwritenonatomiccopy

Information about licenses or restrictions to view or edit the item.

Since
100
Deprecated:
100.4 Use termsOfUse instead.

Provided by category AGSPortalItem(AGSDeprecated).

◆ accessInformation

- (NSString*) accessInformation
readwritenonatomiccopyinherited

The access information about the item.

Since
100

◆ adminGroups

- (NSArray<AGSPortalGroup*>*) adminGroups
readnonatomiccopy

Groups (AGSPortalGroup objects) that this item belongs to which the current portal user is an administrator. Will be nil if they haven't been fetched yet. Use fetchGroupsWithCompletion: to fetch the groups.

Since
100

◆ averageRating

- (CGFloat) averageRating
readnonatomicassign

Average rating of the item.

Since
100

◆ commentCount

- (NSInteger) commentCount
readnonatomicassign

The number of comments on the item.

Since
100

◆ comments

- (NSArray<AGSPortalItemComment*>*) comments
readnonatomiccopy

Array of comments (AGSPortalItemComment) of the item. These need to be fetched explicitly using fetchCommentsWithCompletion:.

Since
100

◆ commentsEnabled

- (BOOL) commentsEnabled
readnonatomicassign

Indicates whether or not comments are enabled for the item.

Since
100

◆ created

- (NSDate*) created
readnonatomicstronginherited

Date on which the item was first saved.

Since
100

◆ extent

- (AGSEnvelope*) extent
readwritenonatomicstronginherited

The default extent of the item. Only applicable to certain item types.

Since
100

◆ folderID

- (NSString*) folderID
readnonatomiccopy

The ID of the folder this item belongs to.

Since
100

◆ itemDescription

- (NSString*) itemDescription
readwritenonatomiccopyinherited

The description of the item, if any.

Since
100

◆ itemID

- (NSString*) itemID
readnonatomiccopyinherited

The ID of the item.

Since
100

◆ loadError

- (NSError*) loadError
readnonatomicstronginherited

The error that was encountered during the most recent load operation. Will be nil if the operation succeeded.

Since
100

◆ loadStatus

- (AGSLoadStatus) loadStatus
readrequirednonatomicassigninherited

Status of the load operation.

Since
100

◆ locale

- (NSLocale*) locale
readnonatomicstrong

The item's language and country information.

Since
100

◆ memberGroups

- (NSArray<AGSPortalGroup*>*) memberGroups
readnonatomiccopy

Groups (AGSPortalGroup objects) that this item belongs to which the current portal user is a member. Will be nil if they haven't been fetched yet. Use fetchGroupsWithCompletion: to fetch the groups.

Since
100

◆ modified

- (NSDate*) modified
readnonatomicstronginherited

Date on which the item was modified.

Since
100

◆ name

- (NSString*) name
readnonatomiccopyinherited

The file name of the item for file types.

Since
100.5

◆ otherGroups

- (NSArray<AGSPortalGroup*>*) otherGroups
readnonatomiccopy

Groups (AGSPortalGroup objects) that this item belongs to that are public or shared to the user's organization, but that the current portal user is not a member of. Will be nil if they haven't been fetched yet. Use fetchGroupsWithCompletion: to fetch the groups.

Since
100

◆ owner

- (NSString*) owner
readwritenonatomiccopy

The user who created the item.

Since
100

◆ portal

- (AGSPortal*) portal
readnonatomicstrong

The portal that the item belongs to.

Since
100

◆ ratingCount

- (NSInteger) ratingCount
readnonatomicassign

The number of ratings made by the users on the item.

Since
100

◆ serviceURL

- (NSURL*) serviceURL
readnonatomicstrong

The URL of the service inside the portal item.

Since
100

◆ size

- (long long) size
readnonatomicassign

The size of the item in bytes.

Since
100

◆ snippet

- (NSString*) snippet
readwritenonatomiccopyinherited

Snippet or summary of the item with a character limit of 250 characters.

Since
100

◆ spatialReferenceName

- (NSString*) spatialReferenceName
readwritenonatomiccopyinherited

Spatial reference of the geographic content

Since
100

◆ tags

- (NSArray<NSString*>*) tags
readwritenonatomiccopyinherited

The user defined tags that describe the specified item.

Since
100

◆ termsOfUse

- (NSString*) termsOfUse
readwritenonatomiccopyinherited

The terms of use of the item. It is stored in the "licenseInfo" property in json. The property can contain HTML markup.

Since
100.4

◆ thumbnail

- (AGSLoadableImage*) thumbnail
readnonatomicstronginherited

The thumbnail image of the item. The image needs to be loaded asynchronously by calling loadWithCompletion: (AGSLoadable-p)

If it is nil, there is no item thumbnail.

Since
100

◆ title

- (NSString*) title
readwritenonatomiccopyinherited

Title of the item.

Since
100

◆ type

- (AGSPortalItemType) type
readwritenonatomicassign

The type of the item.

Since
100

◆ typeKeywords

- (NSArray<NSString *>*) typeKeywords
readwritenonatomiccopyinherited

An array of keywords that further describes the type of item. Each item is tagged with a set of type keywords that are derived based on its primary type.

Since
100.5

◆ typeName

- (NSString*) typeName
readnonatomiccopy

The type of the item represented as a string.

Since
100

◆ unknownJSON

- (NSDictionary<NSString*,id>*) unknownJSON
readrequirednonatomiccopyinherited

A dictionary of values that was in the source JSON but was unparsed by API.

Returns
NSDictionary containing the unknown JSON.
Since
100

◆ unsupportedJSON

- (NSDictionary<NSString*,id>*) unsupportedJSON
readnonatomiccopyinherited

A dictionary of values that are supported by the REST API, but not exposed through the SDK API.

Returns
NSDictionary containing the unsupported JSON.
Since
100

◆ userRating

- (AGSLoadableValue*) userRating
readnonatomicstrong

The user rating of the item.

If it is nil, there is no rating. Otherwise, the rating is number that needs to be loaded asynchronously by calling loadWithCompletion: (AGSLoadable-p).

Since
100

◆ viewCount

- (NSInteger) viewCount
readnonatomicassign

Number of times a file item type is downloaded for the first time or a text item type is opened. For a URL item type, the numViews property increases the first time a service is opened.

Since
100