diff --git a/Android/MMKV/gradle.properties b/Android/MMKV/gradle.properties index 5995c283..20e76bb1 100644 --- a/Android/MMKV/gradle.properties +++ b/Android/MMKV/gradle.properties @@ -12,6 +12,6 @@ org.gradle.jvmargs=-Xmx1536m # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME_PREFIX=1.0.10 +VERSION_NAME_PREFIX=1.0.11 #VERSION_NAME_SUFFIX=-SNAPSHOT VERSION_NAME_SUFFIX= \ No newline at end of file diff --git a/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKV.java b/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKV.java index 95470502..cff68066 100644 --- a/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKV.java +++ b/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKV.java @@ -40,8 +40,9 @@ public class MMKV implements SharedPreferences, SharedPreferences.Editor { } // call on program start + static private String rootDir = null; public static String initialize(Context context) { - String rootDir = context.getFilesDir().getAbsolutePath() + "/mmkv"; + rootDir = context.getFilesDir().getAbsolutePath() + "/mmkv"; initialize(rootDir); return rootDir; } @@ -56,17 +57,32 @@ public static String initialize(Context context) { static private final int ASHMEM_MODE = 0x4; public static MMKV mmkvWithID(String mmapID) { + if (rootDir == null) { + throw new IllegalStateException("You should Call MMKV.initialize() first."); + } + verifyMMID(mmapID); + long handle = getMMKVWithID(mmapID, SINGLE_PROCESS_MODE, null); return new MMKV(handle); } public static MMKV mmkvWithID(String mmapID, int mode) { + if (rootDir == null) { + throw new IllegalStateException("You should Call MMKV.initialize() first."); + } + verifyMMID(mmapID); + long handle = getMMKVWithID(mmapID, mode, null); return new MMKV(handle); } // cryptKey's length <= 16 public static MMKV mmkvWithID(String mmapID, int mode, String cryptKey) { + if (rootDir == null) { + throw new IllegalStateException("You should Call MMKV.initialize() first."); + } + verifyMMID(mmapID); + long handle = getMMKVWithID(mmapID, mode, cryptKey); return new MMKV(handle); } @@ -76,6 +92,11 @@ public static MMKV mmkvWithID(String mmapID, int mode, String cryptKey) { @Nullable public static MMKV mmkvWithAshmemID(Context context, String mmapID, int size, int mode, String cryptKey) { + if (rootDir == null) { + throw new IllegalStateException("You should Call MMKV.initialize() first."); + } + verifyMMID(mmapID); + String processName = MMKVContentProvider.getProcessNameByPID(context, android.os.Process.myPid()); if (processName == null || processName.length() == 0) { @@ -104,8 +125,8 @@ public static MMKV mmkvWithID(String mmapID, int mode, String cryptKey) { if (parcelableMMKV != null) { MMKV mmkv = parcelableMMKV.toMMKV(); if (mmkv != null) { - System.out.println(mmkv.mmapID() + " fd = " + mmkv.ashmemFD() - + ", meta fd = " + mmkv.ashmemMetaFD()); + System.out.println(mmkv.mmapID() + " fd = " + mmkv.ashmemFD() + + ", meta fd = " + mmkv.ashmemMetaFD()); } return mmkv; } @@ -120,12 +141,26 @@ public static MMKV mmkvWithID(String mmapID, int mode, String cryptKey) { return null; } + private static void verifyMMID(String mmapID) { + if (mmapID.indexOf('/') >= 0) { + throw new IllegalArgumentException("\"/\" is not allowed inside mmapID"); + } + } + public static MMKV defaultMMKV() { + if (rootDir == null) { + throw new IllegalStateException("You should Call MMKV.initialize() first."); + } + long handle = getDefaultMMKV(SINGLE_PROCESS_MODE, null); return new MMKV(handle); } public static MMKV defaultMMKV(int mode, String cryptKey) { + if (rootDir == null) { + throw new IllegalStateException("You should Call MMKV.initialize() first."); + } + long handle = getDefaultMMKV(mode, cryptKey); return new MMKV(handle); } diff --git a/Android/MMKV/mmkvdemo/build.gradle b/Android/MMKV/mmkvdemo/build.gradle index cac71d40..b4e363b6 100644 --- a/Android/MMKV/mmkvdemo/build.gradle +++ b/Android/MMKV/mmkvdemo/build.gradle @@ -57,7 +57,7 @@ dependencies { // implementation project(':mmkv') implementation 'com.tencent:mmkv:1.0.10' // implementation 'com.tencent:mmkv:1.0.10-SNAPSHOT' - implementation 'com.android.support:appcompat-v7:27.1.1' + implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..3ed8625c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,34 @@ +#MMKV Change Log + +##v1.0.11 / 2018-10-12 +### iOS / macOS +What's new + +* Port to **macOS** +* Support **NSCoding** +You can store NSArray/NSDictionary or any object what implements `` protocol. +* Redesign Swift interface +* Some performance improvement + +Known Issues + +* MMKV use mmapID as its filename, so don't contain any `/` inside mmapID. +* Storing a value of `type A` and getting by `type B` may not work. MMKV does type erasure while storing values. That means it's hard for MMKV to do value-type-checking, if not impossible. + +### Android +What's new + +* Some performance improvement + +Known Issues + +* Getting a MMKV instance with mmapID that contains `/` may fail. +MMKV uses mmapID as its filename, so don't contain any `/` inside mmapID. +* Storing a value of `type A` and getting by `type B` may not work. +MMKV does type erasure while storing values. That means it's hard for MMKV to do value-type-checking, if not impossible. +* `registerOnSharedPreferenceChangeListener` not supported. +This is intended. We believe doing data-change-listener inside a storage framework smells really bad to us. We suggest using something like event-bus to notify any interesting clients. + +##v1.0.10 / 2018-09-21 + + * Initial Release \ No newline at end of file diff --git a/MMKV.podspec b/MMKV.podspec index 5cdf40fa..ae9c5a37 100644 --- a/MMKV.podspec +++ b/MMKV.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "MMKV" - s.version = "1.0.10" + s.version = "1.0.11" s.summary = "MMKV is a cross-platform key-value storage framework developed by WeChat." s.description = <<-DESC diff --git a/iOS/MMKV/MMKV.xcodeproj/project.pbxproj b/iOS/MMKV/MMKV.xcodeproj/project.pbxproj index 384e3311..496d5215 100644 --- a/iOS/MMKV/MMKV.xcodeproj/project.pbxproj +++ b/iOS/MMKV/MMKV.xcodeproj/project.pbxproj @@ -14,7 +14,6 @@ CB1FD4C520469B8800931B5F /* MiniPBUtility.mm in Sources */ = {isa = PBXBuildFile; fileRef = CB1FD4C020469B8800931B5F /* MiniPBUtility.mm */; }; CB1FD4C620469B8800931B5F /* MiniPBCoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = CB1FD4C220469B8800931B5F /* MiniPBCoder.mm */; }; CB1FD4CD2046ACBC00931B5F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB1FD4CC2046ACBC00931B5F /* Foundation.framework */; }; - CB1FD4CF2046ACC100931B5F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB1FD4CE2046ACC100931B5F /* UIKit.framework */; }; CB6DEFA9212E6F010024F0E8 /* AESCrypt.h in Headers */ = {isa = PBXBuildFile; fileRef = CB6DEF9F212E6F010024F0E8 /* AESCrypt.h */; }; CB6DEFAA212E6F010024F0E8 /* opensslconf.h in Headers */ = {isa = PBXBuildFile; fileRef = CB6DEFA1212E6F010024F0E8 /* opensslconf.h */; }; CB6DEFAB212E6F010024F0E8 /* cfb128.c in Sources */ = {isa = PBXBuildFile; fileRef = CB6DEFA2212E6F010024F0E8 /* cfb128.c */; }; @@ -38,7 +37,6 @@ CBC1A90120DA948A00AD5087 /* MiniPBUtility.mm in Sources */ = {isa = PBXBuildFile; fileRef = CB1FD4C020469B8800931B5F /* MiniPBUtility.mm */; }; CBC1A90220DA948A00AD5087 /* MMKV.mm in Sources */ = {isa = PBXBuildFile; fileRef = CB1FD4952046984F00931B5F /* MMKV.mm */; }; CBC1A90420DA94A000AD5087 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CBC1A90320DA94A000AD5087 /* libz.tbd */; }; - CBC1A90520DA94AD00AD5087 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB1FD4CE2046ACC100931B5F /* UIKit.framework */; }; CBC1A90620DA94B900AD5087 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB1FD4CC2046ACBC00931B5F /* Foundation.framework */; }; CBC1A90C20DA97DF00AD5087 /* MMKV.h in Headers */ = {isa = PBXBuildFile; fileRef = CB1FD4942046984F00931B5F /* MMKV.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ @@ -95,7 +93,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - CB1FD4CF2046ACC100931B5F /* UIKit.framework in Frameworks */, CB1FD4CD2046ACBC00931B5F /* Foundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -105,7 +102,6 @@ buildActionMask = 2147483647; files = ( CBC1A90620DA94B900AD5087 /* Foundation.framework in Frameworks */, - CBC1A90520DA94AD00AD5087 /* UIKit.framework in Frameworks */, CBC1A90420DA94A000AD5087 /* libz.tbd in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -393,6 +389,10 @@ MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx"; + VALID_ARCHS = "arm64 armv7 x86_64"; + "VALID_ARCHS[sdk=iphoneos*]" = "arm64 armv7"; + "VALID_ARCHS[sdk=macosx*]" = x86_64; }; name = Debug; }; @@ -443,7 +443,11 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.3; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx"; VALIDATE_PRODUCT = YES; + VALID_ARCHS = "arm64 armv7 x86_64"; + "VALID_ARCHS[sdk=iphoneos*]" = "arm64 armv7"; + "VALID_ARCHS[sdk=macosx*]" = x86_64; }; name = Release; }; @@ -451,11 +455,23 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; + MACOSX_DEPLOYMENT_TARGET = 10.9; OTHER_LDFLAGS = "-ObjC"; + "OTHER_LDFLAGS[sdk=iphoneos*]" = ( + "-ObjC", + "-framework", + UIKit, + ); + "OTHER_LDFLAGS[sdk=iphonesimulator*]" = ( + "-ObjC", + "-framework", + UIKit, + ); PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = "1,2"; VALID_ARCHS = "arm64 armv7"; + "VALID_ARCHS[sdk=macosx*]" = x86_64; }; name = Debug; }; @@ -463,11 +479,23 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; + MACOSX_DEPLOYMENT_TARGET = 10.9; OTHER_LDFLAGS = "-ObjC"; + "OTHER_LDFLAGS[sdk=iphoneos*]" = ( + "-ObjC", + "-framework", + UIKit, + ); + "OTHER_LDFLAGS[sdk=iphonesimulator*]" = ( + "-ObjC", + "-framework", + UIKit, + ); PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = "1,2"; VALID_ARCHS = "arm64 armv7"; + "VALID_ARCHS[sdk=macosx*]" = x86_64; }; name = Release; }; @@ -488,11 +516,21 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.9; + "OTHER_LDFLAGS[sdk=iphoneos*]" = ( + "-framework", + UIKit, + ); + "OTHER_LDFLAGS[sdk=iphonesimulator*]" = ( + "-framework", + UIKit, + ); PRODUCT_BUNDLE_IDENTIFIER = com.tencent.MMKV; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = "1,2"; VALID_ARCHS = "arm64 armv7"; + "VALID_ARCHS[sdk=macosx*]" = x86_64; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -515,11 +553,21 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.9; + "OTHER_LDFLAGS[sdk=iphoneos*]" = ( + "-framework", + UIKit, + ); + "OTHER_LDFLAGS[sdk=iphonesimulator*]" = ( + "-framework", + UIKit, + ); PRODUCT_BUNDLE_IDENTIFIER = com.tencent.MMKV; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = "1,2"; VALID_ARCHS = "arm64 armv7"; + "VALID_ARCHS[sdk=macosx*]" = x86_64; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; diff --git a/iOS/MMKV/MMKV/MMKV.mm b/iOS/MMKV/MMKV/MMKV.mm index ffe88b8b..62d8c29f 100644 --- a/iOS/MMKV/MMKV/MMKV.mm +++ b/iOS/MMKV/MMKV/MMKV.mm @@ -27,7 +27,11 @@ #import "MiniPBCoder.h" #import "MiniPBUtility.h" #import "ScopedLock.hpp" + +#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED #import +#endif + #import #import #import @@ -65,13 +69,10 @@ @implementation MMKV { + (void)initialize { if (self == MMKV.class) { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - g_instanceDic = [NSMutableDictionary dictionary]; - g_instanceLock = [[NSRecursiveLock alloc] init]; - - MMKVInfo(@"pagesize:%d", DEFAULT_MMAP_SIZE); - }); + g_instanceDic = [NSMutableDictionary dictionary]; + g_instanceLock = [[NSRecursiveLock alloc] init]; + + MMKVInfo(@"pagesize:%d", DEFAULT_MMAP_SIZE); } } @@ -127,6 +128,7 @@ - (instancetype)initWithMMapID:(NSString *)mmapID cryptKey:(NSData *)cryptKey { [self loadFromFile]; +#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED auto appState = [UIApplication sharedApplication].applicationState; if (appState == UIApplicationStateBackground) { m_isInBackground = YES; @@ -138,6 +140,7 @@ - (instancetype)initWithMMapID:(NSString *)mmapID cryptKey:(NSData *)cryptKey { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil]; +#endif } return self; } @@ -184,6 +187,7 @@ - (void)onMemoryWarning { [self clearMemoryCache]; } +#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED - (void)didEnterBackground { CScopedLock lock(m_lock); @@ -197,6 +201,7 @@ - (void)didBecomeActive { m_isInBackground = NO; MMKVInfo(@"m_isInBackground:%d", m_isInBackground); } +#endif #pragma mark - really dirty work @@ -1115,15 +1120,18 @@ - (void)removeValuesForKeys:(NSArray *)arrKeys { [self fullWriteback]; } -#pragma mark - borning stuff +#pragma mark - Boring stuff - (void)sync { CScopedLock lock(m_lock); - if (m_needLoadFromFile || ![self isFileValid]) { + if (m_needLoadFromFile || ![self isFileValid] || m_crcPtr == nullptr) { return; } - if (msync(m_ptr, m_size, MS_SYNC) != 0) { - MMKVError(@"fail to msync [%@]:%s", m_mmapID, strerror(errno)); + if (msync(m_ptr, m_actualSize, MS_SYNC) != 0) { + MMKVError(@"fail to msync data file of [%@]:%s", m_mmapID, strerror(errno)); + } + if (msync(m_crcPtr, CRC_FILE_SIZE, MS_SYNC) != 0) { + MMKVError(@"fail to msync crc-32 file of [%@]:%s", m_mmapID, strerror(errno)); } } diff --git a/iOS/MMKV/MMKV/MemoryFile.mm b/iOS/MMKV/MMKV/MemoryFile.mm index f35ab2c0..ba8f4807 100644 --- a/iOS/MMKV/MMKV/MemoryFile.mm +++ b/iOS/MMKV/MMKV/MemoryFile.mm @@ -285,7 +285,9 @@ bool createFile(NSString *nsFilePath) { NSFileManager *oFileMgr = [NSFileManager defaultManager]; // try create file at once NSMutableDictionary *fileAttr = [NSMutableDictionary dictionary]; +#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED [fileAttr setObject:NSFileProtectionCompleteUntilFirstUserAuthentication forKey:NSFileProtectionKey]; +#endif if ([oFileMgr createFileAtPath:nsFilePath contents:nil attributes:fileAttr]) { return true; } @@ -308,6 +310,7 @@ bool createFile(NSString *nsFilePath) { } void tryResetFileProtection(NSString *path) { +#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED @autoreleasepool { NSDictionary *attr = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nullptr]; NSString *protection = [attr valueForKey:NSFileProtectionKey]; @@ -322,6 +325,7 @@ void tryResetFileProtection(NSString *path) { } } } +#endif } bool removeFile(NSString *nsFilePath) { diff --git a/iOS/MMKV/MMKV/MiniPBCoder.mm b/iOS/MMKV/MMKV/MiniPBCoder.mm index d908665b..78842a54 100644 --- a/iOS/MMKV/MMKV/MiniPBCoder.mm +++ b/iOS/MMKV/MMKV/MiniPBCoder.mm @@ -38,9 +38,6 @@ @implementation MiniPBCoder { NSMutableData *m_outputBuffer; MiniCodedOutputData *m_outputData; std::vector *m_encodeItems; - - void *m_formatBuffer; - size_t m_formatBufferSize; } - (id)initForReadingWithData:(NSData *)data { @@ -76,12 +73,6 @@ - (void)dealloc { delete m_outputData; m_outputData = nullptr; } - - if (m_formatBuffer) { - free(m_formatBuffer); - m_formatBuffer = nullptr; - m_formatBufferSize = 0; - } } #pragma mark - encode @@ -134,18 +125,8 @@ - (size_t)prepareObjectForEncode:(NSObject *)obj { if ([obj isKindOfClass:[NSString class]]) { NSString *str = (NSString *) obj; encodeItem->type = PBEncodeItemType_NSString; - size_t maxSize = MAX(1, [str maximumLengthOfBytesUsingEncoding:NSUTF8StringEncoding]); - if (m_formatBufferSize < maxSize) { - m_formatBufferSize = maxSize; - if (m_formatBuffer) { - free(m_formatBuffer); - } - m_formatBuffer = malloc(m_formatBufferSize); - } - NSUInteger realSize = 0; - [str getBytes:m_formatBuffer maxLength:maxSize usedLength:&realSize encoding:NSUTF8StringEncoding options:0 range:NSMakeRange(0, str.length) remainingRange:nullptr]; - NSData *buffer = [NSData dataWithBytes:m_formatBuffer length:realSize]; - encodeItem->value.tmpObjectValue = (void *) CFBridgingRetain(buffer); + NSData *buffer = [str dataUsingEncoding:NSUTF8StringEncoding]; + encodeItem->value.tmpObjectValue = (__bridge_retained void *) buffer; encodeItem->valueSize = static_cast(buffer.length); } else if ([obj isKindOfClass:[NSDate class]]) { NSDate *oDate = (NSDate *) obj; @@ -311,7 +292,7 @@ + (id)decodeContainerOfClass:(Class)cls withValueClass:(Class)valueClass fromDat id obj = nil; @try { MiniPBCoder *oCoder = [[MiniPBCoder alloc] initForReadingWithData:oData]; - if (cls == [NSDictionary class] || cls == [NSMutableDictionary class]) { + if (cls == [NSMutableDictionary class] || cls == [NSDictionary class]) { obj = [oCoder decodeOneDictionaryOfValueClass:valueClass]; } else { MMKVError(@"%@ not recognized as container", NSStringFromClass(cls)); diff --git a/iOS/MMKV/MMKV/Resources/Info.plist b/iOS/MMKV/MMKV/Resources/Info.plist index c357bf89..a2cf988f 100644 --- a/iOS/MMKV/MMKV/Resources/Info.plist +++ b/iOS/MMKV/MMKV/Resources/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.10 + 1.0.11 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/iOS/MMKVDemo/MMKVDemo.xcodeproj/project.pbxproj b/iOS/MMKVDemo/MMKVDemo.xcodeproj/project.pbxproj index 906ee48a..28a242db 100644 --- a/iOS/MMKVDemo/MMKVDemo.xcodeproj/project.pbxproj +++ b/iOS/MMKVDemo/MMKVDemo.xcodeproj/project.pbxproj @@ -17,7 +17,14 @@ CB1FD4D22046AF2400931B5F /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CB1FD4D12046AF2300931B5F /* libz.tbd */; }; CB36F24C20F8A20C009AF46F /* MMKVDemoTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CB36F24B20F8A20C009AF46F /* MMKVDemoTests.mm */; }; CB36F25A20F8D728009AF46F /* MMKVPerformanceTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = CB36F25920F8D728009AF46F /* MMKVPerformanceTest.mm */; }; + CB9C2731215E5DF000448B6C /* libMMKV Static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CB1FD4B52046994D00931B5F /* libMMKV Static.a */; }; + CB9C2733215E5ECC00448B6C /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CB9C2732215E5ECC00448B6C /* libz.tbd */; }; CB9F963920FCA7C500A1C14C /* DemoSwiftUsage.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB9F963820FCA7C500A1C14C /* DemoSwiftUsage.swift */; }; + CBB6C823215CDB9500487192 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB6C822215CDB9500487192 /* AppDelegate.m */; }; + CBB6C826215CDB9500487192 /* ViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = CBB6C825215CDB9500487192 /* ViewController.mm */; }; + CBB6C828215CDB9600487192 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CBB6C827215CDB9600487192 /* Assets.xcassets */; }; + CBB6C82B215CDB9600487192 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CBB6C829215CDB9600487192 /* Main.storyboard */; }; + CBB6C82E215CDB9600487192 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CBB6C82D215CDB9600487192 /* main.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -49,6 +56,13 @@ remoteGlobalIDString = CBC1A8F620DA946200AD5087; remoteInfo = MMKV; }; + CB9C272F215E5D2400448B6C /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = CB1FD4B02046994C00931B5F /* MMKV.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = CB1FD4902046984F00931B5F; + remoteInfo = "MMKV Static"; + }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -68,8 +82,19 @@ CB36F24B20F8A20C009AF46F /* MMKVDemoTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MMKVDemoTests.mm; sourceTree = ""; }; CB36F24D20F8A20C009AF46F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; CB36F25920F8D728009AF46F /* MMKVPerformanceTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MMKVPerformanceTest.mm; sourceTree = ""; }; + CB9C2732215E5ECC00448B6C /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib/libz.tbd; sourceTree = DEVELOPER_DIR; }; CB9F963720FCA7C400A1C14C /* MMKVDemo-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MMKVDemo-Bridging-Header.h"; sourceTree = ""; }; CB9F963820FCA7C500A1C14C /* DemoSwiftUsage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoSwiftUsage.swift; sourceTree = ""; }; + CBB6C81F215CDB9500487192 /* MMKVMacDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MMKVMacDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + CBB6C821215CDB9500487192 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + CBB6C822215CDB9500487192 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + CBB6C824215CDB9500487192 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + CBB6C825215CDB9500487192 /* ViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewController.mm; sourceTree = ""; }; + CBB6C827215CDB9600487192 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + CBB6C82A215CDB9600487192 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + CBB6C82C215CDB9600487192 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + CBB6C82D215CDB9600487192 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + CBB6C82F215CDB9600487192 /* MMKVMacDemo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MMKVMacDemo.entitlements; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -89,6 +114,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + CBB6C81C215CDB9500487192 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + CB9C2733215E5ECC00448B6C /* libz.tbd in Frameworks */, + CB9C2731215E5DF000448B6C /* libMMKV Static.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -98,6 +132,7 @@ CB1FD4B02046994C00931B5F /* MMKV.xcodeproj */, CB1FD42220455E2D00931B5F /* MMKVDemo */, CB36F24A20F8A20C009AF46F /* MMKVDemoTests */, + CBB6C820215CDB9500487192 /* MMKVMacDemo */, CB1FD42120455E2D00931B5F /* Products */, CB1FD45720455F3500931B5F /* Frameworks */, ); @@ -108,6 +143,7 @@ children = ( CB1FD42020455E2D00931B5F /* MMKVDemo.app */, CB36F24920F8A20C009AF46F /* MMKVDemoTests.xctest */, + CBB6C81F215CDB9500487192 /* MMKVMacDemo.app */, ); name = Products; sourceTree = ""; @@ -133,6 +169,7 @@ CB1FD45720455F3500931B5F /* Frameworks */ = { isa = PBXGroup; children = ( + CB9C2732215E5ECC00448B6C /* libz.tbd */, CB1FD4D12046AF2300931B5F /* libz.tbd */, ); name = Frameworks; @@ -157,6 +194,22 @@ path = MMKVDemoTests; sourceTree = ""; }; + CBB6C820215CDB9500487192 /* MMKVMacDemo */ = { + isa = PBXGroup; + children = ( + CBB6C821215CDB9500487192 /* AppDelegate.h */, + CBB6C822215CDB9500487192 /* AppDelegate.m */, + CBB6C824215CDB9500487192 /* ViewController.h */, + CBB6C825215CDB9500487192 /* ViewController.mm */, + CBB6C827215CDB9600487192 /* Assets.xcassets */, + CBB6C829215CDB9600487192 /* Main.storyboard */, + CBB6C82C215CDB9600487192 /* Info.plist */, + CBB6C82D215CDB9600487192 /* main.m */, + CBB6C82F215CDB9600487192 /* MMKVMacDemo.entitlements */, + ); + path = MMKVMacDemo; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -196,6 +249,24 @@ productReference = CB36F24920F8A20C009AF46F /* MMKVDemoTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; + CBB6C81E215CDB9500487192 /* MMKVMacDemo */ = { + isa = PBXNativeTarget; + buildConfigurationList = CBB6C833215CDB9600487192 /* Build configuration list for PBXNativeTarget "MMKVMacDemo" */; + buildPhases = ( + CBB6C81B215CDB9500487192 /* Sources */, + CBB6C81C215CDB9500487192 /* Frameworks */, + CBB6C81D215CDB9500487192 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + CB9C2730215E5D2400448B6C /* PBXTargetDependency */, + ); + name = MMKVMacDemo; + productName = MMKVMacDemo; + productReference = CBB6C81F215CDB9500487192 /* MMKVMacDemo.app */; + productType = "com.apple.product-type.application"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -215,6 +286,10 @@ ProvisioningStyle = Automatic; TestTargetID = CB1FD41F20455E2D00931B5F; }; + CBB6C81E215CDB9500487192 = { + CreatedOnToolsVersion = 10.0; + ProvisioningStyle = Automatic; + }; }; }; buildConfigurationList = CB1FD41B20455E2D00931B5F /* Build configuration list for PBXProject "MMKVDemo" */; @@ -238,6 +313,7 @@ targets = ( CB1FD41F20455E2D00931B5F /* MMKVDemo */, CB36F24820F8A20C009AF46F /* MMKVDemoTests */, + CBB6C81E215CDB9500487192 /* MMKVMacDemo */, ); }; /* End PBXProject section */ @@ -277,6 +353,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + CBB6C81D215CDB9500487192 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CBB6C828215CDB9600487192 /* Assets.xcassets in Resources */, + CBB6C82B215CDB9600487192 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -300,6 +385,16 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + CBB6C81B215CDB9500487192 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CBB6C826215CDB9500487192 /* ViewController.mm in Sources */, + CBB6C82E215CDB9600487192 /* main.m in Sources */, + CBB6C823215CDB9500487192 /* AppDelegate.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -313,6 +408,11 @@ target = CB1FD41F20455E2D00931B5F /* MMKVDemo */; targetProxy = CB36F24E20F8A20C009AF46F /* PBXContainerItemProxy */; }; + CB9C2730215E5D2400448B6C /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "MMKV Static"; + targetProxy = CB9C272F215E5D2400448B6C /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -332,6 +432,14 @@ name = LaunchScreen.storyboard; sourceTree = ""; }; + CBB6C829215CDB9600487192 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + CBB6C82A215CDB9600487192 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -524,6 +632,47 @@ }; name = Release; }; + CBB6C830215CDB9600487192 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_ENTITLEMENTS = MMKVMacDemo/MMKVMacDemo.entitlements; + CODE_SIGN_IDENTITY = "Mac Developer"; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = 52LMU3A345; + INFOPLIST_FILE = MMKVMacDemo/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.lingol.MMKVMacDemo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Debug; + }; + CBB6C831215CDB9600487192 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_ENTITLEMENTS = MMKVMacDemo/MMKVMacDemo.entitlements; + CODE_SIGN_IDENTITY = "Mac Developer"; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = 52LMU3A345; + INFOPLIST_FILE = MMKVMacDemo/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.lingol.MMKVMacDemo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -554,6 +703,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + CBB6C833215CDB9600487192 /* Build configuration list for PBXNativeTarget "MMKVMacDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CBB6C830215CDB9600487192 /* Debug */, + CBB6C831215CDB9600487192 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = CB1FD41820455E2D00931B5F /* Project object */; diff --git a/iOS/MMKVDemo/MMKVMacDemo/AppDelegate.h b/iOS/MMKVDemo/MMKVMacDemo/AppDelegate.h new file mode 100644 index 00000000..46a06633 --- /dev/null +++ b/iOS/MMKVDemo/MMKVMacDemo/AppDelegate.h @@ -0,0 +1,13 @@ +// +// AppDelegate.h +// MMKVMacDemo +// +// Created by Ling Guo on 2018/9/27. +// Copyright © 2018 Lingol. All rights reserved. +// + +#import + +@interface AppDelegate : NSObject + +@end diff --git a/iOS/MMKVDemo/MMKVMacDemo/AppDelegate.m b/iOS/MMKVDemo/MMKVMacDemo/AppDelegate.m new file mode 100644 index 00000000..566ee7d9 --- /dev/null +++ b/iOS/MMKVDemo/MMKVMacDemo/AppDelegate.m @@ -0,0 +1,25 @@ +// +// AppDelegate.m +// MMKVMacDemo +// +// Created by Ling Guo on 2018/9/27. +// Copyright © 2018 Lingol. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + // Insert code here to initialize your application +} + +- (void)applicationWillTerminate:(NSNotification *)aNotification { + // Insert code here to tear down your application +} + +@end diff --git a/iOS/MMKVDemo/MMKVMacDemo/Assets.xcassets/AppIcon.appiconset/Contents.json b/iOS/MMKVDemo/MMKVMacDemo/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..2db2b1c7 --- /dev/null +++ b/iOS/MMKVDemo/MMKVMacDemo/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iOS/MMKVDemo/MMKVMacDemo/Assets.xcassets/Contents.json b/iOS/MMKVDemo/MMKVMacDemo/Assets.xcassets/Contents.json new file mode 100644 index 00000000..da4a164c --- /dev/null +++ b/iOS/MMKVDemo/MMKVMacDemo/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iOS/MMKVDemo/MMKVMacDemo/Base.lproj/Main.storyboard b/iOS/MMKVDemo/MMKVMacDemo/Base.lproj/Main.storyboard new file mode 100644 index 00000000..38ffc6b6 --- /dev/null +++ b/iOS/MMKVDemo/MMKVMacDemo/Base.lproj/Main.storyboard @@ -0,0 +1,717 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS/MMKVDemo/MMKVMacDemo/Info.plist b/iOS/MMKVDemo/MMKVMacDemo/Info.plist new file mode 100644 index 00000000..b084ce94 --- /dev/null +++ b/iOS/MMKVDemo/MMKVMacDemo/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2018 Lingol. All rights reserved. + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + + diff --git a/iOS/MMKVDemo/MMKVMacDemo/MMKVMacDemo.entitlements b/iOS/MMKVDemo/MMKVMacDemo/MMKVMacDemo.entitlements new file mode 100644 index 00000000..f2ef3ae0 --- /dev/null +++ b/iOS/MMKVDemo/MMKVMacDemo/MMKVMacDemo.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/iOS/MMKVDemo/MMKVMacDemo/ViewController.h b/iOS/MMKVDemo/MMKVMacDemo/ViewController.h new file mode 100644 index 00000000..397ee7f3 --- /dev/null +++ b/iOS/MMKVDemo/MMKVMacDemo/ViewController.h @@ -0,0 +1,13 @@ +// +// ViewController.h +// MMKVMacDemo +// +// Created by Ling Guo on 2018/9/27. +// Copyright © 2018 Lingol. All rights reserved. +// + +#import + +@interface ViewController : NSViewController + +@end diff --git a/iOS/MMKVDemo/MMKVMacDemo/ViewController.mm b/iOS/MMKVDemo/MMKVMacDemo/ViewController.mm new file mode 100644 index 00000000..b0e9cd13 --- /dev/null +++ b/iOS/MMKVDemo/MMKVMacDemo/ViewController.mm @@ -0,0 +1,85 @@ +// +// ViewController.m +// MMKVMacDemo +// +// Created by Ling Guo on 2018/9/27. +// Copyright © 2018 Lingol. All rights reserved. +// + +#import "ViewController.h" +#import + +@implementation ViewController { + NSMutableArray *m_arrStrings; + NSMutableArray *m_arrStrKeys; + NSMutableArray *m_arrIntKeys; + + int m_loops; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self funcionalTest]; + + m_loops = 10000; + m_arrStrings = [NSMutableArray arrayWithCapacity:m_loops]; + m_arrStrKeys = [NSMutableArray arrayWithCapacity:m_loops]; + m_arrIntKeys = [NSMutableArray arrayWithCapacity:m_loops]; + for (size_t index = 0; index < m_loops; index++) { + NSString *str = [NSString stringWithFormat:@"%s-%d", __FILE__, rand()]; + [m_arrStrings addObject:str]; + + NSString *strKey = [NSString stringWithFormat:@"str-%zu", index]; + [m_arrStrKeys addObject:strKey]; + + NSString *intKey = [NSString stringWithFormat:@"int-%zu", index]; + [m_arrIntKeys addObject:intKey]; + } +} + +- (void)funcionalTest { + MMKV *mmkv = [MMKV defaultMMKV]; + + [mmkv setBool:YES forKey:@"bool"]; + NSLog(@"bool:%d", [mmkv getBoolForKey:@"bool"]); + + [mmkv setInt32:-1024 forKey:@"int32"]; + NSLog(@"int32:%d", [mmkv getInt32ForKey:@"int32"]); + + [mmkv setUInt32:std::numeric_limits::max() forKey:@"uint32"]; + NSLog(@"uint32:%u", [mmkv getUInt32ForKey:@"uint32"]); + + [mmkv setInt64:std::numeric_limits::min() forKey:@"int64"]; + NSLog(@"int64:%lld", [mmkv getInt64ForKey:@"int64"]); + + [mmkv setUInt64:std::numeric_limits::max() forKey:@"uint64"]; + NSLog(@"uint64:%llu", [mmkv getInt64ForKey:@"uint64"]); + + [mmkv setFloat:-3.1415926 forKey:@"float"]; + NSLog(@"float:%f", [mmkv getFloatForKey:@"float"]); + + [mmkv setDouble:std::numeric_limits::max() forKey:@"double"]; + NSLog(@"double:%f", [mmkv getDoubleForKey:@"double"]); + + [mmkv setObject:@"hello, mmkv" forKey:@"string"]; + NSLog(@"string:%@", [mmkv getObjectOfClass:NSString.class forKey:@"string"]); + + [mmkv setObject:[NSDate date] forKey:@"date"]; + NSLog(@"date:%@", [mmkv getObjectOfClass:NSDate.class forKey:@"date"]); + + [mmkv setObject:[@"hello, mmkv again and again" dataUsingEncoding:NSUTF8StringEncoding] forKey:@"data"]; + NSData *data = [mmkv getObjectOfClass:NSData.class forKey:@"data"]; + NSLog(@"data:%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); + + [mmkv removeValueForKey:@"bool"]; + NSLog(@"bool:%d", [mmkv getBoolForKey:@"bool"]); +} + +- (void)setRepresentedObject:(id)representedObject { + [super setRepresentedObject:representedObject]; + + // Update the view, if already loaded. +} + +@end diff --git a/iOS/MMKVDemo/MMKVMacDemo/main.m b/iOS/MMKVDemo/MMKVMacDemo/main.m new file mode 100644 index 00000000..02d3816c --- /dev/null +++ b/iOS/MMKVDemo/MMKVMacDemo/main.m @@ -0,0 +1,13 @@ +// +// main.m +// MMKVMacDemo +// +// Created by Ling Guo on 2018/9/27. +// Copyright © 2018 Lingol. All rights reserved. +// + +#import + +int main(int argc, const char *argv[]) { + return NSApplicationMain(argc, argv); +} diff --git a/readme.md b/readme.md index 26a1bed9..e429b83d 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ [![license](https://img.shields.io/badge/license-BSD_3-brightgreen.svg?style=flat)](https://github.com/Tencent/MMKV/blob/master/LICENSE.txt) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/MMKV/pulls) -[![Release Version](https://img.shields.io/badge/release-1.0.10-brightgreen.svg)](https://github.com/Tencent/MMKV/releases) +[![Release Version](https://img.shields.io/badge/release-1.0.11-brightgreen.svg)](https://github.com/Tencent/MMKV/releases) [![Platform](https://img.shields.io/badge/Platform-%20iOS%20%7C%20Android-brightgreen.svg)](https://github.com/Tencent/MMKV/wiki/home) 中文版本请参看[这里](./readme_cn.md) @@ -75,8 +75,8 @@ Add the following lines to `build.gradle` on your app module: ```gradle dependencies { - implementation 'com.tencent:mmkv:1.0.10' - // replace "1.0.10" with any available version + implementation 'com.tencent:mmkv:1.0.11' + // replace "1.0.11" with any available version } ``` @@ -122,6 +122,9 @@ For more benchmark data, please refer to [our benchmark](https://github.com/Tenc ## License MMKV is published under the BSD 3-Clause license. For details check out the [LICENSE.TXT](https://github.com/Tencent/MMKV/blob/master/LICENSE.TXT). + +## Change Log +Check out the [CHANGELOG.md](./CHANGELOG.md) for details of change history. ## Contributing diff --git a/readme_cn.md b/readme_cn.md index a71054b4..ad6ac303 100644 --- a/readme_cn.md +++ b/readme_cn.md @@ -59,8 +59,8 @@ NSString *str = [mmkv getObjectOfClass:NSString.class forKey:@"string"]; ```gradle dependencies { - implementation 'com.tencent:mmkv:1.0.10' - // replace "1.0.10" with any available version + implementation 'com.tencent:mmkv:1.0.11' + // replace "1.0.11" with any available version } ``` @@ -107,6 +107,9 @@ MMKV 支持**多进程访问**,更详细的用法参考 [Android Tutorial](htt ## License MMKV 以 BSD 3-Clause 证书开源,详情参见 [LICENSE.TXT](https://github.com/Tencent/MMKV/blob/master/LICENSE.TXT)。 +## 版本历史 +具体版本历史请参看 [CHANGELOG.md](./CHANGELOG.md)。 + ## 参与贡献 如果你有兴趣参与贡献,可以参考 [CONTRIBUTING.md](https://github.com/Tencent/MMKV/blob/master/CONTRIBUTING.md)。 [腾讯开源激励计划](https://opensource.tencent.com/contribution) 鼓励开发者的参与和贡献,期待你的加入。 ## 问题 & 反馈 常见问题参见 [FAQ](https://github.com/Tencent/MMKV/wiki/FAQ_cn),欢迎提 [issues](https://github.com/Tencent/MMKV/issues) 提问反馈。 \ No newline at end of file