Skip to content

Commit 59598fc

Browse files
committed
Initial commit.
0 parents  commit 59598fc

19 files changed

+436
-0
lines changed

CandyCoded.AppSettings.asmdef

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "CandyCoded.AppSettings",
3+
"references": [
4+
"CandyCoded.AppSettings.iOS"
5+
],
6+
"includePlatforms": [
7+
"Editor",
8+
"iOS"
9+
],
10+
"excludePlatforms": [],
11+
"allowUnsafeCode": false,
12+
"overrideReferences": false,
13+
"precompiledReferences": [],
14+
"autoReferenced": true,
15+
"defineConstraints": [],
16+
"versionDefines": [],
17+
"noEngineReferences": false
18+
}

CandyCoded.AppSettings.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 Scott Doxey
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

LICENSE.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Plugins.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Plugins/iOS.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Plugins/iOS/AppSettings.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) Scott Doxey. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information.
2+
3+
using System.Runtime.InteropServices;
4+
5+
namespace CandyCoded.AppSettings.iOS
6+
{
7+
8+
public static class AppSettings
9+
{
10+
11+
[DllImport("__Internal")]
12+
public static extern bool GetBoolean(string key);
13+
14+
[DllImport("__Internal")]
15+
public static extern double GetDouble(string key);
16+
17+
[DllImport("__Internal")]
18+
public static extern float GetFloat(string key);
19+
20+
[DllImport("__Internal")]
21+
public static extern int GetInteger(string key);
22+
23+
[DllImport("__Internal")]
24+
public static extern string GetString(string key);
25+
26+
}
27+
28+
}

Plugins/iOS/AppSettings.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Plugins/iOS/AppSettings.mm

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Copyright (c) Scott Doxey. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information.
2+
3+
#import <Foundation/Foundation.h>
4+
5+
extern "C"
6+
{
7+
8+
const bool GetBoolean(const char* key) {
9+
10+
NSString* keyString = [NSString stringWithUTF8String: key];
11+
12+
const bool value = [[NSUserDefaults standardUserDefaults] boolForKey: keyString];
13+
14+
return value;
15+
16+
}
17+
18+
const double GetDouble(const char* key) {
19+
20+
NSString* keyString = [NSString stringWithUTF8String: key];
21+
22+
const double value = [[NSUserDefaults standardUserDefaults] doubleForKey: keyString];
23+
24+
return value;
25+
26+
}
27+
28+
const float GetFloat(const char* key) {
29+
30+
NSString* keyString = [NSString stringWithUTF8String: key];
31+
32+
const float value = [[NSUserDefaults standardUserDefaults] floatForKey: keyString];
33+
34+
return value;
35+
36+
}
37+
38+
const int GetInteger(const char* key) {
39+
40+
NSString* keyString = [NSString stringWithUTF8String: key];
41+
42+
const int value = (int)[[NSUserDefaults standardUserDefaults] integerForKey: keyString];
43+
44+
return value;
45+
46+
}
47+
48+
const char* GetString(const char* key) {
49+
50+
NSString* keyString = [NSString stringWithUTF8String: key];
51+
52+
NSString* nsValue = [[NSUserDefaults standardUserDefaults] stringForKey: keyString];
53+
54+
if (nsValue) {
55+
56+
char* value = (char*)malloc(nsValue.length + 1);
57+
58+
strcpy(value, [nsValue UTF8String]);
59+
60+
return value;
61+
62+
}
63+
64+
return NULL;
65+
66+
}
67+
68+
}

Plugins/iOS/AppSettings.mm.meta

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)