diff options
Diffstat (limited to 'platform/iphone/icloud.mm')
-rw-r--r-- | platform/iphone/icloud.mm | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/platform/iphone/icloud.mm b/platform/iphone/icloud.mm index c768274b1f..d3086e6cea 100644 --- a/platform/iphone/icloud.mm +++ b/platform/iphone/icloud.mm @@ -48,8 +48,10 @@ ICloud *ICloud::instance = NULL; void ICloud::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_key"), &ICloud::remove_key); + ClassDB::bind_method(D_METHOD("set_key_values"), &ICloud::set_key_values); ClassDB::bind_method(D_METHOD("get_key_value"), &ICloud::get_key_value); + ClassDB::bind_method(D_METHOD("synchronize_key_values"), &ICloud::synchronize_key_values); ClassDB::bind_method(D_METHOD("get_all_key_values"), &ICloud::get_all_key_values); @@ -91,7 +93,7 @@ Variant nsobject_to_variant(NSObject *object) { } else if ([object isKindOfClass:[NSArray class]]) { Array result; NSArray *array = (NSArray *)object; - for (unsigned int i = 0; i < [array count]; ++i) { + for (NSUInteger i = 0; i < [array count]; ++i) { NSObject *value = [array objectAtIndex:i]; result.push_back(nsobject_to_variant(value)); } @@ -149,7 +151,7 @@ Variant nsobject_to_variant(NSObject *object) { NSObject *variant_to_nsobject(Variant v) { if (v.get_type() == Variant::STRING) { return [[[NSString alloc] initWithUTF8String:((String)v).utf8().get_data()] autorelease]; - } else if (v.get_type() == Variant::REAL) { + } else if (v.get_type() == Variant::FLOAT) { return [NSNumber numberWithDouble:(double)v]; } else if (v.get_type() == Variant::INT) { return [NSNumber numberWithLongLong:(long)(int)v]; @@ -159,7 +161,7 @@ NSObject *variant_to_nsobject(Variant v) { NSMutableDictionary *result = [[[NSMutableDictionary alloc] init] autorelease]; Dictionary dic = v; Array keys = dic.keys(); - for (unsigned int i = 0; i < keys.size(); ++i) { + for (int i = 0; i < keys.size(); ++i) { NSString *key = [[[NSString alloc] initWithUTF8String:((String)(keys[i])).utf8().get_data()] autorelease]; NSObject *value = variant_to_nsobject(dic[keys[i]]); @@ -173,7 +175,7 @@ NSObject *variant_to_nsobject(Variant v) { } else if (v.get_type() == Variant::ARRAY) { NSMutableArray *result = [[[NSMutableArray alloc] init] autorelease]; Array arr = v; - for (unsigned int i = 0; i < arr.size(); ++i) { + for (int i = 0; i < arr.size(); ++i) { NSObject *value = variant_to_nsobject(arr[i]); if (value == NULL) { //trying to add something unsupported to the array. cancel the whole array @@ -192,9 +194,8 @@ NSObject *variant_to_nsobject(Variant v) { return NULL; } -Error ICloud::remove_key(Variant p_param) { - String param = p_param; - NSString *key = [[[NSString alloc] initWithUTF8String:param.utf8().get_data()] autorelease]; +Error ICloud::remove_key(String p_param) { + NSString *key = [[[NSString alloc] initWithUTF8String:p_param.utf8().get_data()] autorelease]; NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore]; @@ -207,15 +208,14 @@ Error ICloud::remove_key(Variant p_param) { } //return an array of the keys that could not be set -Variant ICloud::set_key_values(Variant p_params) { - Dictionary params = p_params; - Array keys = params.keys(); +Array ICloud::set_key_values(Dictionary p_params) { + Array keys = p_params.keys(); Array error_keys; - for (unsigned int i = 0; i < keys.size(); ++i) { + for (int i = 0; i < keys.size(); ++i) { String variant_key = keys[i]; - Variant variant_value = params[variant_key]; + Variant variant_value = p_params[variant_key]; NSString *key = [[[NSString alloc] initWithUTF8String:variant_key.utf8().get_data()] autorelease]; if (key == NULL) { @@ -237,10 +237,8 @@ Variant ICloud::set_key_values(Variant p_params) { return error_keys; } -Variant ICloud::get_key_value(Variant p_param) { - String param = p_param; - - NSString *key = [[[NSString alloc] initWithUTF8String:param.utf8().get_data()] autorelease]; +Variant ICloud::get_key_value(String p_param) { + NSString *key = [[[NSString alloc] initWithUTF8String:p_param.utf8().get_data()] autorelease]; NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore]; if (![[store dictionaryRepresentation] objectForKey:key]) { |