LCObject

Objective-C

@interface LCObject : NSObject <NSCoding>

Swift

class LCObject : NSObject, NSCoding

Undocumented

Constructors

  • Undocumented

    Declaration

    Objective-C

    + (nonnull instancetype)objectWithObjectId:(nonnull NSString *)objectId;

    Swift

    convenience init(objectId: String)

Creating a LCObject */

  • Undocumented

    Declaration

    Objective-C

    + (nonnull instancetype)objectWithClassName:(nonnull NSString *)className;
  • Undocumented

    Declaration

    Objective-C

    + (nonnull instancetype)objectWithClassName:(nonnull NSString *)className
                                       objectId:(nonnull NSString *)objectId;

    Swift

    convenience init(className: String, objectId: String)
  • Undocumented

    Declaration

    Objective-C

    + (nonnull instancetype)objectWithClassName:(nonnull NSString *)className
                                     dictionary:(nonnull NSDictionary *)dictionary;

    Swift

    convenience init(className: String, dictionary: [AnyHashable : Any])
  • Undocumented

    Declaration

    Objective-C

    - (nonnull instancetype)initWithClassName:(nonnull NSString *)newClassName;

    Swift

    init(className newClassName: String)

Bahaviour Control

  • If YES, Null value will be converted to nil when getting object for key. Because [NSNull null] is truthy value in Objective-C. Default is YES and suggested.

    Warning

    It takes effects only when getting object for key. You can still use Null in setObject:forKey.

    Declaration

    Objective-C

    + (void)setConvertingNullToNil:(BOOL)yesOrNo;

    Swift

    class func setConvertingNullToNil(_ yesOrNo: Bool)

    Parameters

    yesOrNo

    default is YES.

Managing Object Properties */

  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly, nullable) NSString *objectId;

    Swift

    var objectId: String? { get }
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) NSDate *updatedAt;

    Swift

    var updatedAt: Date? { get }
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) NSDate *createdAt;

    Swift

    var createdAt: Date? { get }
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSString *_Nonnull className;

    Swift

    var className: String { get }
  • ACL

    Undocumented

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) LCACL *ACL;

    Swift

    var acl: LCACL? { get set }
  • Undocumented

    Declaration

    Objective-C

    - (nonnull NSArray *)allKeys;

    Swift

    func allKeys() -> [Any]

Get and set

Array add and remove

  • Undocumented

    Declaration

    Objective-C

    - (void)addObject:(nonnull id)object forKey:(nonnull NSString *)key;

    Swift

    func add(_ object: Any, forKey key: String)
  • Undocumented

    Declaration

    Objective-C

    - (void)addObjectsFromArray:(nonnull NSArray *)objects
                         forKey:(nonnull NSString *)key;

    Swift

    func addObjects(from objects: [Any], forKey key: String)
  • Undocumented

    Declaration

    Objective-C

    - (void)addUniqueObject:(nonnull id)object forKey:(nonnull NSString *)key;

    Swift

    func addUniqueObject(_ object: Any, forKey key: String)
  • Undocumented

    Declaration

    Objective-C

    - (void)addUniqueObjectsFromArray:(nonnull NSArray *)objects
                               forKey:(nonnull NSString *)key;

    Swift

    func addUniqueObjects(from objects: [Any], forKey key: String)
  • Undocumented

    Declaration

    Objective-C

    - (void)removeObject:(nonnull id)object forKey:(nonnull NSString *)key;

    Swift

    func remove(_ object: Any, forKey key: String)
  • Undocumented

    Declaration

    Objective-C

    - (void)removeObjectsInArray:(nonnull NSArray *)objects
                          forKey:(nonnull NSString *)key;

    Swift

    func removeObjects(in objects: [Any], forKey key: String)

Increment

  • Undocumented

    Declaration

    Objective-C

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

    Swift

    func incrementKey(_ key: String)
  • Undocumented

    Declaration

    Objective-C

    - (void)incrementKey:(nonnull NSString *)key
                byAmount:(nonnull NSNumber *)amount;

    Swift

    func incrementKey(_ key: String, byAmount amount: NSNumber)

Saving an Object to LeanCloud */

Saving Many Objects to LeanCloud */

Getting an Object from LeanCloud */

Fetch

Getting Many Objects from LeanCloud */

Removing an Object from LeanCloud */

  • Undocumented

    Declaration

    Objective-C

    - (BOOL)delete;

    Swift

    func delete() -> Bool
  • Undocumented

    Declaration

    Objective-C

    - (BOOL)delete:(NSError *_Nullable *_Nullable)error;

    Swift

    func delete(_ error: NSErrorPointer) -> Bool
  • Undocumented

    Declaration

    Objective-C

    - (BOOL)deleteAndThrowsWithError:(NSError *_Nullable *_Nullable)error;

    Swift

    func deleteAndThrows() throws
  • Undocumented

    Declaration

    Objective-C

    - (void)deleteInBackground;

    Swift

    func deleteInBackground()
  • Undocumented

    Declaration

    Objective-C

    - (void)deleteInBackgroundWithBlock:(nonnull LCBooleanResultBlock)block;

    Swift

    func deleteInBackground(_ block: @escaping LCBooleanResultBlock)
  • Undocumented

    Declaration

    Objective-C

    - (void)deleteEventually;

    Swift

    func deleteEventually()
  • Undocumented

    Declaration

    Objective-C

    - (void)deleteEventuallyWithBlock:(nonnull LCIdResultBlock)block;

    Swift

    func deleteEventually(_ block: @escaping LCIdResultBlock)
  • Undocumented

    Declaration

    Objective-C

    + (BOOL)deleteAll:(nonnull NSArray *)objects;

    Swift

    class func deleteAll(_ objects: [Any]) -> Bool
  • Undocumented

    Declaration

    Objective-C

    + (BOOL)deleteAll:(nonnull NSArray *)objects
                error:(NSError *_Nullable *_Nullable)error;

    Swift

    class func deleteAll(_ objects: [Any], error: ()) throws
  • Deletes all objects specified in object array. The element of objects array is LCObject or its subclass.

    Declaration

    Objective-C

    + (void)deleteAllInBackground:(nonnull NSArray *)objects
                            block:(nonnull LCBooleanResultBlock)block;

    Swift

    class func deleteAll(inBackground objects: [Any], block: @escaping LCBooleanResultBlock)

    Parameters

    objects

    object array

    block

    The block to execute. The block should have the following argument signature: (BOOL succeeded, NSError *error)

  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic) BOOL fetchWhenSave

    Swift

    var fetchWhenSave: Bool { get set }
  • Undocumented

    Declaration

    Objective-C

    + (nullable LCObject *)objectWithDictionary:(nonnull NSDictionary *)dictionary;

    Swift

    /*not inherited*/ init?(dictionary: [AnyHashable : Any])
  • Undocumented

    Declaration

    Objective-C

    - (nonnull NSMutableDictionary *)dictionaryForObject;

    Swift

    func dictionaryForObject() -> NSMutableDictionary
  • Load object properties from JSON dictionary.

    Declaration

    Objective-C

    - (void)objectFromDictionary:(nonnull NSDictionary *)dictionary;

    Swift

    func object(from dictionary: [AnyHashable : Any])

    Parameters

    dictionary

    JSON dictionary

Methods for Subclasses */