...
Objective-C
Code Block |
---|
[[Appoxee shared] setDateValue:[NSDate date] forKey:@"key" withCompletionHandler:^(NSError * _Nullable appoxeeError, id _Nullable data) { if (!appoxeeError) { // Operation was successful. } }]; [[Appoxee shared] setNumberValue:@(1.01) forKey:@"key" withCompletionHandler:^(NSError * _Nullable appoxeeError, id _Nullable data) { if (!appoxeeError) { // Operation was successful. } }]; [[Appoxee shared] incrementNumericKey:@"key" byNumericValue:@(1.6) withCompletionHandler:^(NSError * _Nullable appoxeeError, id _Nullable data) { if (!appoxeeError) { // Operation was successful. } }]; [[Appoxee shared] setStringValue:@"string" forKey:@"key" withCompletionHandler:^(NSError * _Nullable appoxeeError, id _Nullable data) { if (!appoxeeError) { // Operation was successful. } }]; [[Appoxee shared] fetchCustomFieldByKey:@"CustomFieldKey" withCompletionHandler:^(NSError *appoxeeError, id data) { if (!appoxeeError && [data isKindOfClass:[NSDictionary class]]) { NSDictionary *dictionary = (NSDictionary *)data; NSString *key = [[dictionary allKeys] firstObject]; id value = dictionary[key]; // can be of the following types: NSString || NSNumber || NSDate } // If there wan't an error, and data object is nil, then value doesn't exist on the device. }]; |
Swift
Code Block |
---|
Appoxee.shared()?.setDateValue(NSDate(), forKey: "key", withCompletionHandler: { (appoxeeError, data) in if appoxeeError == nil { // Operation was successful. } }) Appoxee.shared()?.setNumberValue(2, forKey: "key", withCompletionHandler: { (appoxeeError, data) in if appoxeeError == nil { // Operation was successful. } }) Appoxee.shared()?.incrementNumericKey("key", byNumericValue: 1, withCompletionHandler: { (appoxeeError, data) in if appoxeeError == nil { // Operation was successful. } }) Appoxee.shared()?.setStringValue("string", forKey: "key", withCompletionHandler: { (appoxeeError, data) in if appoxeeError == nil { // Operation was successful. } }) Appoxee.shared()?.fetchCustomFieldByKey("key", withCompletionHandler: { (appoxeeError, data) in if appoxeeError == nil { if let dictionary = data as? NSDictionary { if let key = data?.allKeys.first { let value = dictionary.objectForKey(key) } } } // If there wan't an error, and data object is nil, then value doesn't exist on the device. }) |