LCObject
@dynamicMemberLookup
open class LCObject : NSObject, Sequence, LCValue, LCValueExtension, InternalOptionalSynchronizing
extension LCObject: LCValueConvertible
LeanCloud Object Type.
-
The application this object belong to.
Declaration
Swift
public let application: LCApplication -
Access Control List.
Declaration
Swift
@objc public dynamic var ACL: LCACL? -
The identifier of this object.
Declaration
Swift
@objc public dynamic private(set) var objectId: LCString? { get } -
The created date of this object.
Declaration
Swift
@objc public dynamic private(set) var createdAt: LCDate? { get } -
The updated date of this object.
Declaration
Swift
@objc public dynamic private(set) var updatedAt: LCDate? { get } -
Undocumented
Declaration
Swift
public var hasObjectId: Bool { get } -
Whether this object has unsync-data to upload to server.
Declaration
Swift
public var hasDataToUpload: Bool { get }
-
Set class name of current type.
The default implementation returns the class name without root module.
Declaration
Swift
open class func objectClassName() -> StringReturn Value
The class name of current type.
-
Register current object class manually.
Declaration
Swift
public static func register()
-
Initializing a new object with default application.
Declaration
Swift
public override required init() -
Initializing a new object with an application.
Declaration
Swift
public required init(application: LCApplication)Parameters
applicationThe application this object belong to.
-
Initializing a new object with an application and a identifier.
Declaration
Swift
public convenience init( application: LCApplication = .default, objectId: LCStringConvertible)Parameters
applicationThe application this object belong to.
objectIdThe identifier of an exist object.
-
Initializing a new object with an application and class name.
Declaration
Swift
public convenience init( application: LCApplication = .default, className: LCStringConvertible)Parameters
applicationThe application this object belong to.
classNameThe class name of this object.
-
Initializing a new object with an application, a identifier and class name.
Declaration
Swift
public convenience init( application: LCApplication = .default, className: LCStringConvertible, objectId: LCStringConvertible)Parameters
applicationThe application this object belong to.
classNameThe class name of this object.
objectIdThe identifier of an exist object.
-
Returns an object initialized from data in a given unarchiver.
Declaration
Swift
public required convenience init?(coder: NSCoder)Parameters
coderAn unarchiver object.
-
Encodes the receiver using a given archiver.
Declaration
Swift
public func encode(with coder: NSCoder)Parameters
coderAn archiver object.
-
Will not do copying, just return a pointer to this object.
Declaration
Swift
open func copy(with zone: NSZone?) -> AnyParameters
zoneUnused, just pass nil.
-
Undocumented
Declaration
Swift
open override func isEqual(_ object: Any?) -> Bool -
Undocumented
Declaration
Swift
open override func value(forKey key: String) -> Any? -
Undocumented
Declaration
Swift
open override func value(forUndefinedKey key: String) -> Any?
-
Declaration
Swift
open func makeIterator() -> DictionaryIterator<String, LCValue>
-
Declaration
Swift
open var jsonValue: Any { get } -
Declaration
Swift
public var rawValue: Any { get }
-
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
keyThe 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?) throwsParameters
keyThe key for which to set the value.
valueThe new value.
-
Unset value for key.
Declaration
Swift
open func unset(_ key: String) throwsParameters
keyThe key for which to unset.
-
Increase a number by amount.
Declaration
Swift
open func increase(_ key: String, by: LCNumberConvertible = 1) throwsParameters
keyThe key of number which you want to increase.
amountThe 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) throwsParameters
keyThe key of array into which you want to append the element.
elementThe element to append.
-
Append one or more elements into an array.
Declaration
Swift
open func append(_ key: String, elements: LCArrayConvertible) throwsParameters
keyThe key of array into which you want to append the elements.
elementsThe 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) throwsParameters
keyThe key of array into which you want to append the element.
elementThe element to append.
uniqueWhether 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) throwsParameters
keyThe key of array into which you want to append the element.
elementsThe array of elements to append.
uniqueWhether append element by unique or not.
-
Remove an element from an array.
Declaration
Swift
open func remove(_ key: String, element: LCValueConvertible) throwsParameters
keyThe key of array from which you want to remove the element.
elementThe element to remove.
-
Remove one or more elements from an array.
Declaration
Swift
open func remove(_ key: String, elements: LCArrayConvertible) throwsParameters
keyThe key of array from which you want to remove the element.
elementsThe array of elements to remove.
-
Get relation object for key.
Declaration
Swift
open func relationForKey(_ key: String) -> LCRelationParameters
keyThe 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) throwsParameters
keyThe key of relation into which you want to insert the object.
objectThe object to insert.
-
Remove an object from a relation.
Declaration
Swift
open func removeRelation(_ key: String, object: LCObject) throwsParameters
keyThe key of relation from which you want to remove the object.
objectThe object to remove.
-
Options for saving action.
See moreDeclaration
Swift
public enum SaveOption -
Save a batch of objects in one request synchronously.
Declaration
Swift
public class func save( _ objects: [LCObject], options: [LCObject.SaveOption] = []) -> LCBooleanResultParameters
objectsAn array of objects to be saved.
optionsSee
LCObject.SaveOption, default is[], it will be applyed to all objects.Return Value
-
Save a batch of objects in one request asynchronously.
Declaration
Swift
@discardableResult public class func save( _ objects: [LCObject], options: [LCObject.SaveOption] = [], completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequestParameters
objectsAn array of objects to be saved.
optionsSee
LCObject.SaveOption, default is[], it will be applyed to all objects.completionQueueThe queue where the
completionbe called, default isDispatchQueue.main.completionThe callback of result.
Return Value
-
Save object and its all descendant objects synchronously.
Declaration
Swift
public func save( options: [LCObject.SaveOption] = []) -> LCBooleanResultParameters
optionsSee
LCObject.SaveOption, default is[].Return Value
-
Save object and its all descendant objects asynchronously.
Declaration
Swift
@discardableResult public func save( options: [LCObject.SaveOption] = [], completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequestParameters
optionsSee
LCObject.SaveOption, default is[].completionQueueThe queue where the
completionbe called, default isDispatchQueue.main.completionThe callback of result.
Return Value
-
Delete a batch of objects in one request synchronously.
Declaration
Swift
public static func delete( _ objects: [LCObject]) -> LCBooleanResultParameters
objectsAn array of objects to be deleted.
Return Value
-
Delete a batch of objects in one request asynchronously.
Declaration
Swift
@discardableResult public static func delete( _ objects: [LCObject], completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequestParameters
objectsAn array of objects to be deleted.
completionQueueThe queue where the
completionbe called, default isDispatchQueue.main.completionThe callback of result.
Return Value
-
Delete current object synchronously.
Declaration
Swift
public func delete() -> LCBooleanResult -
Delete current object asynchronously.
Declaration
Swift
@discardableResult public func delete( completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequestParameters
completionQueueThe queue where the
completionbe called, default isDispatchQueue.main.completionThe callback of result.
Return Value
-
Fetch a batch of objects in one request synchronously.
Declaration
Swift
public static func fetch( _ objects: [LCObject], keys: [String]? = nil) -> LCBooleanResultParameters
objectsAn array of objects to be fetched.
keysSpecify only return the values of the
keys, or not return the values of thekeyswhen add a “-” prefix to the key.Return Value
-
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) -> LCRequestParameters
objectsAn array of objects to be fetched.
keysSpecify only return the values of the
keys, or not return the values of thekeyswhen add a “-” prefix to the key.completionQueueThe queue where the
completionbe called, default isDispatchQueue.main.completionThe callback of result.
Return Value
-
Fetch object from server synchronously.
Declaration
Swift
public func fetch( keys: [String]? = nil) -> LCBooleanResultParameters
keysSpecify only return the values of the
keys, or not return the values of thekeyswhen add a “-” prefix to the key.Return Value
-
Fetch object from server asynchronously.
Declaration
Swift
@discardableResult public func fetch( keys: [String]? = nil, completionQueue: DispatchQueue = .main, completion: @escaping (LCBooleanResult) -> Void) -> LCRequestParameters
keysSpecify only return the values of the
keys, or not return the values of thekeyswhen add a “-” prefix to the key.completionQueueThe queue where the
completionbe called, default isDispatchQueue.main.completionThe callback of result.
Return Value
-
Declaration
Swift
public var lcValue: LCValue { get }
View on GitHub
Install in Dash
LCObject Class Reference