ZDCShareList

@interface ZDCShareList

ZDCShareList encapsulates the permissions information for a node.

By default, a node inherits the same permissions as its parent node. For example, a newly created node in the root of the Home container will only include permissions for the localUser (rw).

To share a node with another user will require you to add permissions for that user here. For information on sharing data with other users:

  • amazing website resource #1
  • amazing website resource #2

Advanced Options:

The ZeroDark.cloud server also allows you to share to resources other than users. For example, your application may wish to share information with your custom backend system. Here’s how that works:

  • Sign into the ZeroDark.cloud developer dashboard
  • Create a server instance (you’ll receive a UUID for this instance)
  • Register one or more endpoints so that the ZeroDark.cloud system can notify your server(s)
  • Then, when nodes are created/modified/deleted, which have in their shareList a key of SRV:, the ZeroDark.cloud will notify your server(s) via the current set of registered endpoints.
  • Creates an empty shareList.

    Declaration

    Objective-C

    - (nonnull id)init;

    Swift

    init()
  • Creates a shareList by parsing the given dictionary. This dictionary comes from a RCRD file.

    Declaration

    Objective-C

    - (nonnull id)initWithDictionary:(nullable NSDictionary *)dictionary;

    Swift

    init(dictionary: [AnyHashable : Any]?)
  • Returns the raw version of the shareList, as it would appear in the cloud.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSDictionary *_Nonnull rawDictionary;

    Swift

    var rawDictionary: [AnyHashable : Any] { get }
  • Returns the number of shareItems in the list

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSUInteger count;

    Swift

    var count: UInt { get }
  • Returns the number of shareItems in the list, counting only the shareItems that are for a user.

    Declaration

    Objective-C

    - (NSUInteger)countOfUserIDs;

    Swift

    func countOfUserIDs() -> UInt
  • Returns the number of shareItems in the list, counting only the shareItems that are for a user, and excluing the given userID.

    This is a common use case. For example, you want to know how many other people the node is being shared with. I.e. the count excluding the localUserID.

    Declaration

    Objective-C

    - (NSUInteger)countOfUserIDsExcluding:(nullable NSString *)userID;

    Swift

    func countOfUserIDs(excluding userID: String?) -> UInt
  • Returns whether or not a shareItem exists for the given key. Keys are a compound component: {type}:{identifier}

    Declaration

    Objective-C

    - (BOOL)hasShareItemForKey:(nonnull NSString *)key;

    Swift

    func hasShareItem(forKey key: String) -> Bool
  • Returns whether or not a shareItem exists for the given userID.

    Declaration

    Objective-C

    - (BOOL)hasShareItemForUserID:(nonnull NSString *)userID;

    Swift

    func hasShareItem(forUserID userID: String) -> Bool
  • Returns whether or not a shareItem exists for the given serverID.

    Declaration

    Objective-C

    - (BOOL)hasShareItemForServerID:(nonnull NSString *)serverID;

    Swift

    func hasShareItem(forServerID serverID: String) -> Bool
  • Returns the shareItem for the given key. Keys are a compound component: {type}:{identifier}

    Declaration

    Objective-C

    - (nullable ZDCShareItem *)shareItemForKey:(nonnull NSString *)key;

    Swift

    func shareItem(forKey key: String) -> ZDCShareItem?
  • Returns the shareItem for the given userID.

    Declaration

    Objective-C

    - (nullable ZDCShareItem *)shareItemForUserID:(nonnull NSString *)userID;

    Swift

    func shareItem(forUserID userID: String) -> ZDCShareItem?
  • Returns the shareItem for the gien serverID.

    Declaration

    Objective-C

    - (nullable ZDCShareItem *)shareItemForServerID:(nonnull NSString *)serverID;

    Swift

    func shareItem(forServerID serverID: String) -> ZDCShareItem?
  • Sets the shareItem for the given key. Keys are a compound component: {type}:{identifier}

    Declaration

    Objective-C

    - (BOOL)addShareItem:(nonnull ZDCShareItem *)item
                  forKey:(nonnull NSString *)key;

    Swift

    func add(_ item: ZDCShareItem, forKey key: String) -> Bool

    Return Value

    NO if a shareItem already exists for the given key. In which case you shouldn’t be replacing it. You should be modifying the existing shareItem. That way your changes are properly tracked & merged.

  • Sets the shareItem for the given userID.

    Declaration

    Objective-C

    - (BOOL)addShareItem:(nonnull ZDCShareItem *)item
               forUserID:(nonnull NSString *)userID;

    Swift

    func add(_ item: ZDCShareItem, forUserID userID: String) -> Bool

    Return Value

    NO if a shareItem already exists for the given key. In which case you shouldn’t be replacing it. You should be modifying the existing shareItem. That way your changes are properly tracked & merged.

  • Sets the shareItem for the given serverID.

    Declaration

    Objective-C

    - (BOOL)addShareItem:(nonnull ZDCShareItem *)item
             forServerID:(nonnull NSString *)serverID;

    Swift

    func add(_ item: ZDCShareItem, forServerID serverID: String) -> Bool

    Return Value

    NO if a shareItem already exists for the given key. In which case you shouldn’t be replacing it. You should be modifying the existing shareItem. That way your changes are properly tracked & merged.

  • Removes the shareItem with the given key. Keys are a compound component: {type}:{identifier}

    Declaration

    Objective-C

    - (void)removeShareItemForKey:(nonnull NSString *)key;

    Swift

    func removeShareItem(forKey key: String)
  • Removes the shareItem for the given userID.

    Declaration

    Objective-C

    - (void)removeShareItemForUserID:(nonnull NSString *)userID;

    Swift

    func removeShareItem(forUserID userID: String)
  • Removes the shareItem for the given serverID.

    Declaration

    Objective-C

    - (void)removeShareItemForServerID:(nonnull NSString *)serverID;

    Swift

    func removeShareItem(forServerID serverID: String)
  • Clears the list - afterwards there will be zero shareItems in the list.

    Declaration

    Objective-C

    - (void)removeAllShareItems;

    Swift

    func removeAllShareItems()
  • Returns all keys in the list. Keys are a compound component: {type}:{identifier}

    Declaration

    Objective-C

    - (nonnull NSArray<NSString *> *)allKeys;

    Swift

    func allKeys() -> [String]
  • Returns all userID’s in the list.

    Each key is a compound component: {type}:{identifier} If the ‘type’ == ZDCShareKeyType_User, then the ‘identifier’ component is a userID. This method extracts all the userID’s from those keys which are user keys.

    See

    countOfUserIDs

    See

    countOfUserIDsExcluding:

    Declaration

    Objective-C

    - (nonnull NSArray<NSString *> *)allUserIDs;

    Swift

    func allUserIDs() -> [String]
  • Enumerates all items in the list.

    Declaration

    Objective-C

    - (void)enumerateListWithBlock:(nonnull void (^)(NSString *_Nonnull,
                                                     ZDCShareItem *_Nonnull,
                                                     BOOL *_Nonnull))block;

    Swift

    func enumerate(_ block: @escaping (String, ZDCShareItem, UnsafeMutablePointer<ObjCBool>) -> Void)
  • Returns true if the parameter is of type ZDCShareList, and all values are the same.

    Declaration

    Objective-C

    - (BOOL)isEqual:(nullable id)another;

    Swift

    func isEqual(_ another: Any?) -> Bool
  • Returns true if both lists contain the same shareItems.

    Declaration

    Objective-C

    - (BOOL)isEqualToShareList:(nonnull ZDCShareList *)another;

    Swift

    func isEqual(to another: ZDCShareList) -> Bool
  • Keys are a compound component: {type}:{identifier} This method returns whether the type is ZDCShareKeyType_User.

    Declaration

    Objective-C

    + (BOOL)isUserKey:(nonnull NSString *)key;

    Swift

    class func isUserKey(_ key: String) -> Bool
  • Keys are a compound component: {type}:{identifier} This method returns whether the type is ZDCShareKeyType_Server.

    Declaration

    Objective-C

    + (BOOL)isServerKey:(nonnull NSString *)key;

    Swift

    class func isServerKey(_ key: String) -> Bool
  • Creates a key: UID:{userID_goes_here}

    Declaration

    Objective-C

    + (nonnull NSString *)keyForUserID:(nonnull NSString *)userID;

    Swift

    class func key(forUserID userID: String) -> String
  • Extracts userID from key: UID:{userID_extracted_from_here}

    Declaration

    Objective-C

    + (nullable NSString *)userIDFromKey:(nonnull NSString *)key;

    Swift

    class func userID(fromKey key: String) -> String?
  • Creates a key: SRV:{serverID_goes_here}

    Declaration

    Objective-C

    + (nonnull NSString *)keyForServerID:(nonnull NSString *)serverID;

    Swift

    class func key(forServerID serverID: String) -> String
  • Extracts serverID from key: SRV:{serverID_extracted_from_here}

    Declaration

    Objective-C

    + (nullable NSString *)serverIDFromKey:(nonnull NSString *)key;

    Swift

    class func serverID(fromKey key: String) -> String?
  • Returns the default set of permissions for the given trunk (top-level root node). These are hard-coded on a per-trunk basis.

    Declaration

    Objective-C

    + (nonnull ZDCShareList *)defaultShareListForTrunk:(ZDCTreesystemTrunk)trunk
                                       withLocalUserID:
                                           (nonnull NSString *)localUserID;

    Swift

    class func defaultShareList(for trunk: ZDCTreesystemTrunk, withLocalUserID localUserID: String) -> ZDCShareList