LCObject

@dynamicMemberLookup
open class LCObject : NSObject, LCValue, LCValueExtension, Sequence
extension LCObject: LCValueConvertible

LeanCloud Object Type.

Property

Subclassing

  • Set class name of current type.

    The default implementation returns the class name without root module.

    Declaration

    Swift

    open class func objectClassName() -> String

    Return Value

    The class name of current type.

  • Register current object class manually.

    Declaration

    Swift

    public static func register()

Initialization

NSCoding

  • Returns an object initialized from data in a given unarchiver.

    Declaration

    Swift

    public required convenience init?(coder: NSCoder)

    Parameters

    coder

    An unarchiver object.

  • Encodes the receiver using a given archiver.

    Declaration

    Swift

    public func encode(with coder: NSCoder)

    Parameters

    coder

    An archiver object.

NSCopying

  • Will not do copying, just return a pointer to this object.

    Declaration

    Swift

    open func copy(with zone: NSZone?) -> Any

    Parameters

    zone

    Unused, just pass nil.

NSObjectProtocol

Sequence

LCValue

Operation

  • Undocumented

    Declaration

    Swift

    open subscript(key: String) -> LCValueConvertible? { get set }
  • Undocumented

    Declaration

    Swift

    open subscript(dynamicMember key: String) -> LCValueConvertible? { get set }
  • Get value for key.

    Declaration

    Swift

    open func get(_ key: String) -> LCValueConvertible?

    Parameters

    key

    The key for which to get the value.

    Return Value

    The value for key.

  • Set value for key.

    This method allows you to set a value of a Swift built-in type which confirms LCValueConvertible.

    Declaration

    Swift

    open func set(_ key: String, value: LCValueConvertible?) throws

    Parameters

    key

    The key for which to set the value.

    value

    The new value.

  • Unset value for key.

    Declaration

    Swift

    open func unset(_ key: String) throws

    Parameters

    key

    The key for which to unset.

  • Increase a number by amount.

    Declaration

    Swift

    open func increase(_ key: String, by: LCNumberConvertible = 1) throws

    Parameters

    key

    The key of number which you want to increase.

    amount

    The amount to increase. If no amount is specified, 1 is used by default.

  • Append an element into an array.

    Declaration

    Swift

    open func append(_ key: String, element: LCValueConvertible) throws

    Parameters

    key

    The key of array into which you want to append the element.

    element

    The element to append.

  • Append one or more elements into an array.

    Declaration

    Swift

    open func append(_ key: String, elements: LCArrayConvertible) throws

    Parameters

    key

    The key of array into which you want to append the elements.

    elements

    The array of elements to append.

  • Append an element into an array with unique option.

    Declaration

    Swift

    open func append(_ key: String, element: LCValueConvertible, unique: Bool) throws

    Parameters

    key

    The key of array into which you want to append the element.

    element

    The element to append.

    unique

    Whether append element by unique or not. If true, element will not be appended if it had already existed in array; otherwise, element will always be appended.

  • Append one or more elements into an array with unique option.

    Seealso

    append(key: String, element: LCValue, unique: Bool)

    Declaration

    Swift

    open func append(_ key: String, elements: LCArrayConvertible, unique: Bool) throws

    Parameters

    key

    The key of array into which you want to append the element.

    elements

    The array of elements to append.

    unique

    Whether append element by unique or not.

  • Remove an element from an array.

    Declaration

    Swift

    open func remove(_ key: String, element: LCValueConvertible) throws

    Parameters

    key

    The key of array from which you want to remove the element.

    element

    The element to remove.

  • Remove one or more elements from an array.

    Declaration

    Swift

    open func remove(_ key: String, elements: LCArrayConvertible) throws

    Parameters

    key

    The key of array from which you want to remove the element.

    elements

    The array of elements to remove.

  • Get relation object for key.

    Declaration

    Swift

    open func relationForKey(_ key: String) -> LCRelation

    Parameters

    key

    The key where relationship based on.

    Return Value

    The relation for key.

  • Insert an object into a relation.

    Declaration

    Swift

    open func insertRelation(_ key: String, object: LCObject) throws

    Parameters

    key

    The key of relation into which you want to insert the object.

    object

    The object to insert.

  • Remove an object from a relation.

    Declaration

    Swift

    open func removeRelation(_ key: String, object: LCObject) throws

    Parameters

    key

    The key of relation from which you want to remove the object.

    object

    The object to remove.

Save

Delete

Fetch

  • Fetch a batch of objects in one request synchronously.

    Declaration

    Swift

    public static func fetch(
        _ objects: [LCObject],
        keys: [String]? = nil)
        -> LCBooleanResult

    Parameters

    objects

    An array of objects to be fetched.

    keys

    Specify only return the values of the keys, or not return the values of the keys when add a “-” prefix to the key.

    Return Value

    LCBooleanResult.

  • Fetch a batch of objects in one request asynchronously.

    Declaration

    Swift

    @discardableResult
    public static func fetch(
        _ objects: [LCObject],
        keys: [String]? = nil,
        completionQueue: DispatchQueue = .main,
        completion: @escaping (LCBooleanResult) -> Void)
        -> LCRequest

    Parameters

    objects

    An array of objects to be fetched.

    keys

    Specify only return the values of the keys, or not return the values of the keys when add a “-” prefix to the key.

    completionQueue

    The queue where the completion be called, default is DispatchQueue.main.

    completion

    The callback of result.

    Return Value

    LCRequest.

  • Fetch object from server synchronously.

    Declaration

    Swift

    public func fetch(
        keys: [String]? = nil)
        -> LCBooleanResult

    Parameters

    keys

    Specify only return the values of the keys, or not return the values of the keys when add a “-” prefix to the key.

    Return Value

    LCBooleanResult.

  • Fetch object from server asynchronously.

    Declaration

    Swift

    @discardableResult
    public func fetch(
        keys: [String]? = nil,
        completionQueue: DispatchQueue = .main,
        completion: @escaping (LCBooleanResult) -> Void)
        -> LCRequest

    Parameters

    keys

    Specify only return the values of the keys, or not return the values of the keys when add a “-” prefix to the key.

    completionQueue

    The queue where the completion be called, default is DispatchQueue.main.

    completion

    The callback of result.

    Return Value

    LCRequest.

  • Declaration

    Swift

    public var lcValue: LCValue { get }