project_files/HedgewarsMobile/Classes/ExtraCategories.m
branchios-develop
changeset 13172 c129707eb1e6
parent 13171 ba5c794adae3
--- a/project_files/HedgewarsMobile/Classes/ExtraCategories.m	Sun Mar 11 22:39:40 2018 +0100
+++ b/project_files/HedgewarsMobile/Classes/ExtraCategories.m	Sun Mar 11 23:24:05 2018 +0100
@@ -190,3 +190,19 @@
 }
 
 @end
+
+
+#pragma mark -
+@implementation NSUserDefaults (setNonExisting)
+
+- (void)setDefaultValue:(nullable id)value forNonExistingKey:(NSString *_Nonnull)key {
+    if ([self objectForKey:key] == nil) {
+        [self setObject:value forKey:key];
+    }
+}
+
+- (void)setDefaultBool:(BOOL)boolValue forNonExistingKey:(NSString *_Nonnull)key {
+    [self setDefaultValue:[NSNumber numberWithBool:boolValue] forNonExistingKey:key];
+}
+
+@end