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() -> String
Return 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
application
The 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
application
The application this object belong to.
objectId
The 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
application
The application this object belong to.
className
The 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
application
The application this object belong to.
className
The class name of this object.
objectId
The identifier of an exist object.
-
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.
-
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.
-
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
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.
-
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] = []) -> LCBooleanResult
Parameters
objects
An array of objects to be saved.
options
See
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) -> LCRequest
Parameters
objects
An array of objects to be saved.
options
See
LCObject.SaveOption
, default is[]
, it will be applyed to all objects.completionQueue
The queue where the
completion
be called, default isDispatchQueue.main
.completion
The callback of result.
Return Value
-
Save object and its all descendant objects synchronously.
Declaration
Swift
public func save( options: [LCObject.SaveOption] = []) -> LCBooleanResult
Parameters
options
See
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) -> LCRequest
Parameters
options
See
LCObject.SaveOption
, default is[]
.completionQueue
The queue where the
completion
be called, default isDispatchQueue.main
.completion
The callback of result.
Return Value
-
Delete a batch of objects in one request synchronously.
Declaration
Swift
public static func delete( _ objects: [LCObject]) -> LCBooleanResult
Parameters
objects
An 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) -> LCRequest
Parameters
objects
An array of objects to be deleted.
completionQueue
The queue where the
completion
be called, default isDispatchQueue.main
.completion
The 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) -> LCRequest
Parameters
completionQueue
The queue where the
completion
be called, default isDispatchQueue.main
.completion
The 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) -> 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 thekeys
when 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) -> 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 thekeys
when add a “-” prefix to the key.completionQueue
The queue where the
completion
be called, default isDispatchQueue.main
.completion
The callback of result.
Return Value
-
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 thekeys
when 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) -> LCRequest
Parameters
keys
Specify only return the values of the
keys
, or not return the values of thekeys
when add a “-” prefix to the key.completionQueue
The queue where the
completion
be called, default isDispatchQueue.main
.completion
The callback of result.
Return Value
-
Declaration
Swift
public var lcValue: LCValue { get }