diff --git a/ld01/ld01.xcodeproj/project.pbxproj b/ld01/ld01.xcodeproj/project.pbxproj new file mode 100644 index 0000000000000000000000000000000000000000..c6185f92ca0492795bd8bb3198ba6c2cfcc492d0 --- /dev/null +++ b/ld01/ld01.xcodeproj/project.pbxproj @@ -0,0 +1,350 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + F38926B524A86D80002F724A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F38926B424A86D80002F724A /* AppDelegate.m */; }; + F38926B824A86D80002F724A /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F38926B724A86D80002F724A /* SceneDelegate.m */; }; + F38926BB24A86D80002F724A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F38926BA24A86D80002F724A /* ViewController.m */; }; + F38926BE24A86D80002F724A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F38926BC24A86D80002F724A /* Main.storyboard */; }; + F38926C024A86D85002F724A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F38926BF24A86D85002F724A /* Assets.xcassets */; }; + F38926C324A86D85002F724A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F38926C124A86D85002F724A /* LaunchScreen.storyboard */; }; + F38926C624A86D85002F724A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F38926C524A86D85002F724A /* main.m */; }; + F38926CD24A87425002F724A /* libtest.so in Resources */ = {isa = PBXBuildFile; fileRef = F38926CC24A87425002F724A /* libtest.so */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + F38926B024A86D80002F724A /* ld01.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ld01.app; sourceTree = BUILT_PRODUCTS_DIR; }; + F38926B324A86D80002F724A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + F38926B424A86D80002F724A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + F38926B624A86D80002F724A /* SceneDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = ""; }; + F38926B724A86D80002F724A /* SceneDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = ""; }; + F38926B924A86D80002F724A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + F38926BA24A86D80002F724A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + F38926BD24A86D80002F724A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + F38926BF24A86D85002F724A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + F38926C224A86D85002F724A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + F38926C424A86D85002F724A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + F38926C524A86D85002F724A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + F38926CC24A87425002F724A /* libtest.so */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libtest.so; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + F38926AD24A86D80002F724A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + F38926A724A86D80002F724A = { + isa = PBXGroup; + children = ( + F38926B224A86D80002F724A /* ld01 */, + F38926B124A86D80002F724A /* Products */, + ); + sourceTree = ""; + }; + F38926B124A86D80002F724A /* Products */ = { + isa = PBXGroup; + children = ( + F38926B024A86D80002F724A /* ld01.app */, + ); + name = Products; + sourceTree = ""; + }; + F38926B224A86D80002F724A /* ld01 */ = { + isa = PBXGroup; + children = ( + F38926CC24A87425002F724A /* libtest.so */, + F38926B324A86D80002F724A /* AppDelegate.h */, + F38926B424A86D80002F724A /* AppDelegate.m */, + F38926B624A86D80002F724A /* SceneDelegate.h */, + F38926B724A86D80002F724A /* SceneDelegate.m */, + F38926B924A86D80002F724A /* ViewController.h */, + F38926BA24A86D80002F724A /* ViewController.m */, + F38926BC24A86D80002F724A /* Main.storyboard */, + F38926BF24A86D85002F724A /* Assets.xcassets */, + F38926C124A86D85002F724A /* LaunchScreen.storyboard */, + F38926C424A86D85002F724A /* Info.plist */, + F38926C524A86D85002F724A /* main.m */, + ); + path = ld01; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + F38926AF24A86D80002F724A /* ld01 */ = { + isa = PBXNativeTarget; + buildConfigurationList = F38926C924A86D85002F724A /* Build configuration list for PBXNativeTarget "ld01" */; + buildPhases = ( + F38926AC24A86D80002F724A /* Sources */, + F38926AD24A86D80002F724A /* Frameworks */, + F38926AE24A86D80002F724A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ld01; + productName = ld01; + productReference = F38926B024A86D80002F724A /* ld01.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + F38926A824A86D80002F724A /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1140; + ORGANIZATIONNAME = admin; + TargetAttributes = { + F38926AF24A86D80002F724A = { + CreatedOnToolsVersion = 11.4.1; + }; + }; + }; + buildConfigurationList = F38926AB24A86D80002F724A /* Build configuration list for PBXProject "ld01" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = F38926A724A86D80002F724A; + productRefGroup = F38926B124A86D80002F724A /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + F38926AF24A86D80002F724A /* ld01 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + F38926AE24A86D80002F724A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F38926C324A86D85002F724A /* LaunchScreen.storyboard in Resources */, + F38926CD24A87425002F724A /* libtest.so in Resources */, + F38926C024A86D85002F724A /* Assets.xcassets in Resources */, + F38926BE24A86D80002F724A /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + F38926AC24A86D80002F724A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F38926BB24A86D80002F724A /* ViewController.m in Sources */, + F38926B524A86D80002F724A /* AppDelegate.m in Sources */, + F38926C624A86D85002F724A /* main.m in Sources */, + F38926B824A86D80002F724A /* SceneDelegate.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + F38926BC24A86D80002F724A /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + F38926BD24A86D80002F724A /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + F38926C124A86D85002F724A /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + F38926C224A86D85002F724A /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + F38926C724A86D85002F724A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + F38926C824A86D85002F724A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + F38926CA24A86D85002F724A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = ld01/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.test.ld01; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + F38926CB24A86D85002F724A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = ld01/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.test.ld01; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + F38926AB24A86D80002F724A /* Build configuration list for PBXProject "ld01" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F38926C724A86D85002F724A /* Debug */, + F38926C824A86D85002F724A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F38926C924A86D85002F724A /* Build configuration list for PBXNativeTarget "ld01" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F38926CA24A86D85002F724A /* Debug */, + F38926CB24A86D85002F724A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = F38926A824A86D80002F724A /* Project object */; +} diff --git a/ld01/ld01/AppDelegate.h b/ld01/ld01/AppDelegate.h new file mode 100644 index 0000000000000000000000000000000000000000..7065a02e67fd3970ea4c59305d6f1866602e5f41 --- /dev/null +++ b/ld01/ld01/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// ld01 +// +// Created by on 2020/6/28. +// Copyright © 2020 admin. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + + +@end + diff --git a/ld01/ld01/AppDelegate.m b/ld01/ld01/AppDelegate.m new file mode 100644 index 0000000000000000000000000000000000000000..5c8c8791c235f4cd072b8a9c2a7462711084f8ae --- /dev/null +++ b/ld01/ld01/AppDelegate.m @@ -0,0 +1,41 @@ +// +// AppDelegate.m +// ld01 +// +// Created by on 2020/6/28. +// Copyright © 2020 admin. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + + +#pragma mark - UISceneSession lifecycle + + +- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role]; +} + + +- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet *)sceneSessions { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. +} + + +@end diff --git a/ld01/ld01/Assets.xcassets/AppIcon.appiconset/Contents.json b/ld01/ld01/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..9221b9bb1a35f5de270a41afa01305478221ae32 --- /dev/null +++ b/ld01/ld01/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ld01/ld01/Assets.xcassets/Contents.json b/ld01/ld01/Assets.xcassets/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..73c00596a7fca3f3d4bdd64053b69d86745f9e10 --- /dev/null +++ b/ld01/ld01/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ld01/ld01/Base.lproj/LaunchScreen.storyboard b/ld01/ld01/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000000000000000000000000000000000..865e9329f3767a7c1dd66294b8025bf81dee7d2c --- /dev/null +++ b/ld01/ld01/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ld01/ld01/Base.lproj/Main.storyboard b/ld01/ld01/Base.lproj/Main.storyboard new file mode 100644 index 0000000000000000000000000000000000000000..808a21ce779bae61839ac1803bc4e2c854578f5e --- /dev/null +++ b/ld01/ld01/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ld01/ld01/Info.plist b/ld01/ld01/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..7b6037c25e51ed37e3887a4a7bb1c5438eb9fbcb --- /dev/null +++ b/ld01/ld01/Info.plist @@ -0,0 +1,64 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + SceneDelegate + UISceneStoryboardFile + Main + + + + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/ld01/ld01/SceneDelegate.h b/ld01/ld01/SceneDelegate.h new file mode 100644 index 0000000000000000000000000000000000000000..fc6f070ade8562b52892ad9a25f57bc8cd7d4216 --- /dev/null +++ b/ld01/ld01/SceneDelegate.h @@ -0,0 +1,16 @@ +// +// SceneDelegate.h +// ld01 +// +// Created by on 2020/6/28. +// Copyright © 2020 admin. All rights reserved. +// + +#import + +@interface SceneDelegate : UIResponder + +@property (strong, nonatomic) UIWindow * window; + +@end + diff --git a/ld01/ld01/SceneDelegate.m b/ld01/ld01/SceneDelegate.m new file mode 100644 index 0000000000000000000000000000000000000000..17810e5593768f2c37a2154c93f5d3f2606f6114 --- /dev/null +++ b/ld01/ld01/SceneDelegate.m @@ -0,0 +1,58 @@ +// +// SceneDelegate.m +// ld01 +// +// Created by on 2020/6/28. +// Copyright © 2020 admin. All rights reserved. +// + +#import "SceneDelegate.h" + +@interface SceneDelegate () + +@end + +@implementation SceneDelegate + + +- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). +} + + +- (void)sceneDidDisconnect:(UIScene *)scene { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). +} + + +- (void)sceneDidBecomeActive:(UIScene *)scene { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. +} + + +- (void)sceneWillResignActive:(UIScene *)scene { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). +} + + +- (void)sceneWillEnterForeground:(UIScene *)scene { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. +} + + +- (void)sceneDidEnterBackground:(UIScene *)scene { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. +} + + +@end diff --git a/ld01/ld01/ViewController.h b/ld01/ld01/ViewController.h new file mode 100644 index 0000000000000000000000000000000000000000..22b47ad16f06d1102558398bf37c6a4fefac17cd --- /dev/null +++ b/ld01/ld01/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// ld01 +// +// Created by on 2020/6/28. +// Copyright © 2020 admin. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/ld01/ld01/ViewController.m b/ld01/ld01/ViewController.m new file mode 100644 index 0000000000000000000000000000000000000000..f86fed7dc62d3a2a0c931225e835113ff13c5b1f --- /dev/null +++ b/ld01/ld01/ViewController.m @@ -0,0 +1,87 @@ +// +// ViewController.m +// ld01 +// +// Created by on 2020/6/28. +// Copyright © 2020 admin. All rights reserved. +// + +#import "ViewController.h" +#import +#include + +@interface ViewController () +@property (nonatomic,strong) id runtime_Player; +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. +// [self runtimePlay]; + + printf("come in\n"); + + NSString* resourcePath = [[NSBundle mainBundle] resourcePath]; + NSString* dlPath = [NSString stringWithFormat: @"%@/libtest.so", resourcePath]; + const char* cdlpath = [dlPath UTF8String]; + + void *lib = dlopen("libtest.so", RTLD_LAZY); + + void *handler = dlopen(cdlpath, RTLD_LAZY); + printf("dlopen - %sn", dlerror()); + assert(handler != NULL); + + void (*pTest)(int); + pTest = (void (*)(int))dlsym(handler, "add"); + + (*pTest)(10); + + dlclose(handler); + + printf("go out\n"); + + + return; + NSString * const* foregroundConstant = (NSString * const *) dlsym(RTLD_DEFAULT, "UIApplicationWillEnterForegroundNotification"); + NSLog(@"foregroundConstant:%@",*foregroundConstant); + if (foregroundConstant) { + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(enteringForeground) + name:*foregroundConstant + object:nil]; + } + +} + +- (void)runtimePlay{ + // 获取音乐资源路径 + NSString *path = [[NSBundle mainBundle] pathForResource:@"rain" ofType:@"mp3"]; + // 加载库到当前运行程序 + void *lib = dlopen("/System/Library/Frameworks/AVFoundation.framework/AVFoundation", RTLD_LAZY); + if (lib) { + // 获取类名称 + Class playerClass = NSClassFromString(@"AVAudioPlayer"); + // 获取函数方法 + SEL selector = NSSelectorFromString(@"initWithData:error:"); + // 调用实例化对象方法 + _runtime_Player = [[playerClass alloc] performSelector:selector withObject:[NSData dataWithContentsOfFile:path] withObject:nil]; + // 获取函数方法 + selector = NSSelectorFromString(@"play"); + // 调用播放方法 + [_runtime_Player performSelector:selector]; + NSLog(@"动态加载播放"); + } +} + +- (void) enteringForeground { + NSLog(@"enteringForeground"); +} + +- (void) dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + + +@end diff --git a/ld01/ld01/main.m b/ld01/ld01/main.m new file mode 100644 index 0000000000000000000000000000000000000000..8f09527a4d3b65f663696ef1677480be921715f4 --- /dev/null +++ b/ld01/ld01/main.m @@ -0,0 +1,19 @@ +// +// main.m +// ld01 +// +// Created by on 2020/6/28. +// Copyright © 2020 admin. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + NSString * appDelegateClassName; + @autoreleasepool { + // Setup code that might create autoreleased objects goes here. + appDelegateClassName = NSStringFromClass([AppDelegate class]); + } + return UIApplicationMain(argc, argv, nil, appDelegateClassName); +} diff --git a/ld01/libtest.so b/ld01/libtest.so new file mode 100755 index 0000000000000000000000000000000000000000..ac2bfb120f388985de2a4aa7c17fabe8fff72b67 Binary files /dev/null and b/ld01/libtest.so differ diff --git a/ld01/main.c b/ld01/main.c new file mode 100644 index 0000000000000000000000000000000000000000..b748f89918605789f9c8ce796bcdf83daf389e08 --- /dev/null +++ b/ld01/main.c @@ -0,0 +1,26 @@ + +#include +#include +#include +#include +#include /* 必须加这个头文件 */ +#include + +int main(int argc, char *argv[]) +{ + printf("come in\n"); + + void *handler = dlopen("libtest.so", RTLD_NOW); + assert(handler != NULL); + + void (*pTest)(int); + pTest = (void (*)(int))dlsym(handler, "add"); + + (*pTest)(10); + + dlclose(handler); + + printf("go out\n"); + return 0; +} + diff --git a/ld01/test.c b/ld01/test.c new file mode 100644 index 0000000000000000000000000000000000000000..9502155055890b5fda34a7e61f875b5471889925 --- /dev/null +++ b/ld01/test.c @@ -0,0 +1,21 @@ + +#include + +#ifdef __cplusplus +extern "C"{ + +#endif + +void add(int num) +{ + printf("*****************************************\n"); + printf("This is ok, the number is okay. %d\n", num); + printf("*****************************************\n"); +} + + +#ifdef __cplusplus + } + +#endif + diff --git a/swiftdemo/swift01/readme.txt b/swiftdemo/swift01/readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..36cb183b1ddd36114f17117da7fff656772645c2 --- /dev/null +++ b/swiftdemo/swift01/readme.txt @@ -0,0 +1,2 @@ +参考https://github.com/captain-charisma/GhostChallenge + diff --git a/swiftdemo/swift01/swift01.xcodeproj/project.pbxproj b/swiftdemo/swift01/swift01.xcodeproj/project.pbxproj new file mode 100644 index 0000000000000000000000000000000000000000..a4b9168970016a0798ea6fd9871d73e19b7268ac --- /dev/null +++ b/swiftdemo/swift01/swift01.xcodeproj/project.pbxproj @@ -0,0 +1,397 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + F3FD53F824EBA848000462CD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3FD53F724EBA848000462CD /* AppDelegate.swift */; }; + F3FD53FA24EBA848000462CD /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3FD53F924EBA848000462CD /* SceneDelegate.swift */; }; + F3FD53FC24EBA848000462CD /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3FD53FB24EBA848000462CD /* MasterViewController.swift */; }; + F3FD53FE24EBA848000462CD /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3FD53FD24EBA848000462CD /* DetailViewController.swift */; }; + F3FD540124EBA848000462CD /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F3FD53FF24EBA848000462CD /* Main.storyboard */; }; + F3FD540324EBA84E000462CD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F3FD540224EBA84E000462CD /* Assets.xcassets */; }; + F3FD540624EBA84E000462CD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F3FD540424EBA84E000462CD /* LaunchScreen.storyboard */; }; + F3FD540E24EBA8FF000462CD /* MainTableViewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3FD540D24EBA8FF000462CD /* MainTableViewDataSource.swift */; }; + F3FD541324EBD162000462CD /* Resource.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3FD541224EBD162000462CD /* Resource.swift */; }; + F3FD541524EBD391000462CD /* JSONPlaceholder.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3FD541424EBD391000462CD /* JSONPlaceholder.swift */; }; + F3FD541724ECB0BC000462CD /* WebService.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3FD541624ECB0BC000462CD /* WebService.swift */; }; + F3FD541A24ECB542000462CD /* Dream.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3FD541924ECB542000462CD /* Dream.swift */; }; + F3FD541C24ECB82A000462CD /* DreamData.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3FD541B24ECB82A000462CD /* DreamData.swift */; }; + F3FD541F24ECBC9B000462CD /* DateFmt.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3FD541E24ECBC9B000462CD /* DateFmt.swift */; }; + F3FD542124ECBCB1000462CD /* RandomNumberGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3FD542024ECBCB1000462CD /* RandomNumberGenerator.swift */; }; + F3FD542324ECC313000462CD /* NotificationName_Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3FD542224ECC313000462CD /* NotificationName_Ext.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + F3FD53F424EBA848000462CD /* swift01.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = swift01.app; sourceTree = BUILT_PRODUCTS_DIR; }; + F3FD53F724EBA848000462CD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + F3FD53F924EBA848000462CD /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + F3FD53FB24EBA848000462CD /* MasterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterViewController.swift; sourceTree = ""; }; + F3FD53FD24EBA848000462CD /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = ""; }; + F3FD540024EBA848000462CD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + F3FD540224EBA84E000462CD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + F3FD540524EBA84E000462CD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + F3FD540724EBA84E000462CD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + F3FD540D24EBA8FF000462CD /* MainTableViewDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainTableViewDataSource.swift; sourceTree = ""; }; + F3FD541224EBD162000462CD /* Resource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Resource.swift; sourceTree = ""; }; + F3FD541424EBD391000462CD /* JSONPlaceholder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONPlaceholder.swift; sourceTree = ""; }; + F3FD541624ECB0BC000462CD /* WebService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebService.swift; sourceTree = ""; }; + F3FD541924ECB542000462CD /* Dream.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dream.swift; sourceTree = ""; }; + F3FD541B24ECB82A000462CD /* DreamData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DreamData.swift; sourceTree = ""; }; + F3FD541E24ECBC9B000462CD /* DateFmt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DateFmt.swift; sourceTree = ""; }; + F3FD542024ECBCB1000462CD /* RandomNumberGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RandomNumberGenerator.swift; sourceTree = ""; }; + F3FD542224ECC313000462CD /* NotificationName_Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationName_Ext.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + F3FD53F124EBA848000462CD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + F3FD53EB24EBA848000462CD = { + isa = PBXGroup; + children = ( + F3FD53F624EBA848000462CD /* swift01 */, + F3FD53F524EBA848000462CD /* Products */, + ); + sourceTree = ""; + }; + F3FD53F524EBA848000462CD /* Products */ = { + isa = PBXGroup; + children = ( + F3FD53F424EBA848000462CD /* swift01.app */, + ); + name = Products; + sourceTree = ""; + }; + F3FD53F624EBA848000462CD /* swift01 */ = { + isa = PBXGroup; + children = ( + F3FD541D24ECBC9B000462CD /* Util */, + F3FD541824ECB533000462CD /* Model */, + F3FD53F724EBA848000462CD /* AppDelegate.swift */, + F3FD53F924EBA848000462CD /* SceneDelegate.swift */, + F3FD53FB24EBA848000462CD /* MasterViewController.swift */, + F3FD541224EBD162000462CD /* Resource.swift */, + F3FD541624ECB0BC000462CD /* WebService.swift */, + F3FD541424EBD391000462CD /* JSONPlaceholder.swift */, + F3FD540D24EBA8FF000462CD /* MainTableViewDataSource.swift */, + F3FD542224ECC313000462CD /* NotificationName_Ext.swift */, + F3FD53FD24EBA848000462CD /* DetailViewController.swift */, + F3FD53FF24EBA848000462CD /* Main.storyboard */, + F3FD540224EBA84E000462CD /* Assets.xcassets */, + F3FD540424EBA84E000462CD /* LaunchScreen.storyboard */, + F3FD540724EBA84E000462CD /* Info.plist */, + ); + path = swift01; + sourceTree = ""; + }; + F3FD541824ECB533000462CD /* Model */ = { + isa = PBXGroup; + children = ( + F3FD541924ECB542000462CD /* Dream.swift */, + F3FD541B24ECB82A000462CD /* DreamData.swift */, + ); + path = Model; + sourceTree = ""; + }; + F3FD541D24ECBC9B000462CD /* Util */ = { + isa = PBXGroup; + children = ( + F3FD541E24ECBC9B000462CD /* DateFmt.swift */, + F3FD542024ECBCB1000462CD /* RandomNumberGenerator.swift */, + ); + path = Util; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + F3FD53F324EBA848000462CD /* swift01 */ = { + isa = PBXNativeTarget; + buildConfigurationList = F3FD540A24EBA84E000462CD /* Build configuration list for PBXNativeTarget "swift01" */; + buildPhases = ( + F3FD53F024EBA848000462CD /* Sources */, + F3FD53F124EBA848000462CD /* Frameworks */, + F3FD53F224EBA848000462CD /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = swift01; + productName = swift01; + productReference = F3FD53F424EBA848000462CD /* swift01.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + F3FD53EC24EBA848000462CD /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1140; + LastUpgradeCheck = 1140; + ORGANIZATIONNAME = admin; + TargetAttributes = { + F3FD53F324EBA848000462CD = { + CreatedOnToolsVersion = 11.4.1; + }; + }; + }; + buildConfigurationList = F3FD53EF24EBA848000462CD /* Build configuration list for PBXProject "swift01" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = F3FD53EB24EBA848000462CD; + productRefGroup = F3FD53F524EBA848000462CD /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + F3FD53F324EBA848000462CD /* swift01 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + F3FD53F224EBA848000462CD /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F3FD540624EBA84E000462CD /* LaunchScreen.storyboard in Resources */, + F3FD540324EBA84E000462CD /* Assets.xcassets in Resources */, + F3FD540124EBA848000462CD /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + F3FD53F024EBA848000462CD /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F3FD541F24ECBC9B000462CD /* DateFmt.swift in Sources */, + F3FD541724ECB0BC000462CD /* WebService.swift in Sources */, + F3FD53F824EBA848000462CD /* AppDelegate.swift in Sources */, + F3FD542324ECC313000462CD /* NotificationName_Ext.swift in Sources */, + F3FD53FA24EBA848000462CD /* SceneDelegate.swift in Sources */, + F3FD541A24ECB542000462CD /* Dream.swift in Sources */, + F3FD53FC24EBA848000462CD /* MasterViewController.swift in Sources */, + F3FD540E24EBA8FF000462CD /* MainTableViewDataSource.swift in Sources */, + F3FD541524EBD391000462CD /* JSONPlaceholder.swift in Sources */, + F3FD53FE24EBA848000462CD /* DetailViewController.swift in Sources */, + F3FD541324EBD162000462CD /* Resource.swift in Sources */, + F3FD541C24ECB82A000462CD /* DreamData.swift in Sources */, + F3FD542124ECBCB1000462CD /* RandomNumberGenerator.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + F3FD53FF24EBA848000462CD /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + F3FD540024EBA848000462CD /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + F3FD540424EBA84E000462CD /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + F3FD540524EBA84E000462CD /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + F3FD540824EBA84E000462CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + F3FD540924EBA84E000462CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + F3FD540B24EBA84E000462CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = swift01/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.test.swift01; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + F3FD540C24EBA84E000462CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = swift01/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.test.swift01; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + F3FD53EF24EBA848000462CD /* Build configuration list for PBXProject "swift01" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F3FD540824EBA84E000462CD /* Debug */, + F3FD540924EBA84E000462CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + F3FD540A24EBA84E000462CD /* Build configuration list for PBXNativeTarget "swift01" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F3FD540B24EBA84E000462CD /* Debug */, + F3FD540C24EBA84E000462CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = F3FD53EC24EBA848000462CD /* Project object */; +} diff --git a/swiftdemo/swift01/swift01/AppDelegate.swift b/swiftdemo/swift01/swift01/AppDelegate.swift new file mode 100644 index 0000000000000000000000000000000000000000..174d7c8ed0f761b2249e837f5994610e5c187102 --- /dev/null +++ b/swiftdemo/swift01/swift01/AppDelegate.swift @@ -0,0 +1,37 @@ +// +// AppDelegate.swift +// swift01 +// +// Created by on 2020/8/18. +// Copyright © 2020 admin. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/swiftdemo/swift01/swift01/Assets.xcassets/AppIcon.appiconset/Contents.json b/swiftdemo/swift01/swift01/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..9221b9bb1a35f5de270a41afa01305478221ae32 --- /dev/null +++ b/swiftdemo/swift01/swift01/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/swiftdemo/swift01/swift01/Assets.xcassets/Contents.json b/swiftdemo/swift01/swift01/Assets.xcassets/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..73c00596a7fca3f3d4bdd64053b69d86745f9e10 --- /dev/null +++ b/swiftdemo/swift01/swift01/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/swiftdemo/swift01/swift01/Base.lproj/LaunchScreen.storyboard b/swiftdemo/swift01/swift01/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000000000000000000000000000000000..865e9329f3767a7c1dd66294b8025bf81dee7d2c --- /dev/null +++ b/swiftdemo/swift01/swift01/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/swiftdemo/swift01/swift01/Base.lproj/Main.storyboard b/swiftdemo/swift01/swift01/Base.lproj/Main.storyboard new file mode 100644 index 0000000000000000000000000000000000000000..99a041387a58987db2b050e83dffd800321211b6 --- /dev/null +++ b/swiftdemo/swift01/swift01/Base.lproj/Main.storyboard @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/swiftdemo/swift01/swift01/DetailViewController.swift b/swiftdemo/swift01/swift01/DetailViewController.swift new file mode 100644 index 0000000000000000000000000000000000000000..e41549fd0cce9dbbeb30e1721efa65b578a78433 --- /dev/null +++ b/swiftdemo/swift01/swift01/DetailViewController.swift @@ -0,0 +1,40 @@ +// +// DetailViewController.swift +// swift01 +// +// Created by on 2020/8/18. +// Copyright © 2020 admin. All rights reserved. +// + +import UIKit + +class DetailViewController: UIViewController { + + @IBOutlet weak var detailDescriptionLabel: UILabel! + + + func configureView() { + // Update the user interface for the detail item. + if let detail = detailItem { + if let label = detailDescriptionLabel { + label.text = detail.description + } + } + } + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + configureView() + } + + var detailItem: Dream? { + didSet { + // Update the view. + configureView() + } + } + + +} + diff --git a/swiftdemo/swift01/swift01/Info.plist b/swiftdemo/swift01/swift01/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..e7f6f585eee944f72dd4f44ce3c66a4f00190e6a --- /dev/null +++ b/swiftdemo/swift01/swift01/Info.plist @@ -0,0 +1,74 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UIStatusBarTintParameters + + UINavigationBar + + Style + UIBarStyleDefault + Translucent + + + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/swiftdemo/swift01/swift01/JSONPlaceholder.swift b/swiftdemo/swift01/swift01/JSONPlaceholder.swift new file mode 100644 index 0000000000000000000000000000000000000000..210a6ea9e56c22da319fcca502d61895510dfb15 --- /dev/null +++ b/swiftdemo/swift01/swift01/JSONPlaceholder.swift @@ -0,0 +1,46 @@ +// +// JSONPlaceholder.swift +// swift01 +// +// Created by on 2020/8/18. +// Copyright © 2020 admin. All rights reserved. +// + +import Foundation + +struct JSONPlaceholder { + static let url = URL(string: "https://jsonplaceholder.typicode.com/posts") + + let userID : Int + let id : Int + let title : String + let body : String + + enum Keys: String, CodingKey { + case userId + case id + case title + case body + } + +} + +extension JSONPlaceholder : Decodable { + init(from decoder: Decoder) throws { + let values = try decoder.container(keyedBy: Keys.self) + userID = try values.decode(Int.self, forKey: .userId) + title = try values.decode(String.self, forKey: .title) + id = try values.decode(Int.self, forKey: .id) + body = try values.decode(String.self, forKey: .body) + + } +} + +extension JSONPlaceholder { + static let all = Resource<[JSONPlaceholder]>(JSONPlaceholder.url!) { + (data) -> [JSONPlaceholder]? in + let posts = try? JSONDecoder().decode([JSONPlaceholder].self, from: data) + return posts + + } +} diff --git a/swiftdemo/swift01/swift01/MainTableViewDataSource.swift b/swiftdemo/swift01/swift01/MainTableViewDataSource.swift new file mode 100644 index 0000000000000000000000000000000000000000..61bf08ff41c4b51c381a92980736545a307bb89e --- /dev/null +++ b/swiftdemo/swift01/swift01/MainTableViewDataSource.swift @@ -0,0 +1,54 @@ +// +// MainTableViewDataSource.swift +// swift01 +// +// Created by on 2020/8/18. +// Copyright © 2020 admin. All rights reserved. +// + +import Foundation +import UIKit + +class MainTableViewDataSource: NSObject { + let webService = WebService() + var dateMachines = [DateFmt]() + + fileprivate func setupDates() { + for _ in 0...13 { + let datefmt = DateFmt(date: Date()) + + print("===",datefmt) + dateMachines.append(datefmt) + + + } + } + + override init() { + super.init() + + setupDates() + getData() + } +} + +extension MainTableViewDataSource { + func getData() { + webService.load(resource: JSONPlaceholder.all) { [weak self] (posts) in + guard let placeholder = posts else {return} +// print(placeholder) + _ = self?.convertPlaceholderToDreams(withPosts: placeholder) + NotificationCenter.default.post(name: .dataRetrieved, object: nil) + } + } + + func convertPlaceholderToDreams(withPosts placeholders: [JSONPlaceholder]) -> [Dream] { + return placeholders.map { placeholder in + let randomNumber = 1 + let dateMachine = dateMachines[randomNumber] + let dream = Dream(title: placeholder.title, dateString: dateMachine.dateString, tags:["happy, funny, sad, awesome"], description: placeholder.body) + ApplicationData.DatabaseData.write(toData: dream) + return dream + } + } +} diff --git a/swiftdemo/swift01/swift01/MasterViewController.swift b/swiftdemo/swift01/swift01/MasterViewController.swift new file mode 100644 index 0000000000000000000000000000000000000000..632fd166ca2219cfeb116c5ced0e881d3e7095b8 --- /dev/null +++ b/swiftdemo/swift01/swift01/MasterViewController.swift @@ -0,0 +1,122 @@ +// +// MasterViewController.swift +// swift01 +// +// Created by on 2020/8/18. +// Copyright © 2020 admin. All rights reserved. +// + +import UIKit + +class MasterViewController: UITableViewController { + let dataSource = MainTableViewDataSource() + + var detailViewController: DetailViewController? = nil + var objects = [Any]() + + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + navigationItem.leftBarButtonItem = editButtonItem + + setupNotificationObservers() + + let addButton = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(insertNewObject(_:))) + navigationItem.rightBarButtonItem = addButton + if let split = splitViewController { + let controllers = split.viewControllers + detailViewController = (controllers[controllers.count-1] as! UINavigationController).topViewController as? DetailViewController + } + } + + override func viewWillAppear(_ animated: Bool) { + clearsSelectionOnViewWillAppear = splitViewController!.isCollapsed + super.viewWillAppear(animated) + } + + @objc + func insertNewObject(_ sender: Any) { + objects.insert(NSDate(), at: 0) + let indexPath = IndexPath(row: 0, section: 0) + tableView.insertRows(at: [indexPath], with: .automatic) + } + + // MARK: - Segues + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + if segue.identifier == "showDetail" { + if let indexPath = tableView.indexPathForSelectedRow { +// let object = objects[indexPath.row] as! NSDate + let object = dreams[indexPath.row] + let controller = (segue.destination as! UINavigationController).topViewController as! DetailViewController + controller.detailItem = object + controller.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem + controller.navigationItem.leftItemsSupplementBackButton = true + detailViewController = controller + } + } + } + + // MARK: - Table View + + override func numberOfSections(in tableView: UITableView) -> Int { + return 1 + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { +// return objects.count + return dreams.count + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) +// let object = objects[indexPath.row] as! NSDate +// cell.textLabel!.text = object.description + let dream: Dream + dream = dreams[indexPath.row] + cell.textLabel!.text = dream.description + + return cell + } + + override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { + // Return false if you do not want the specified item to be editable. + return true + } + + override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { + if editingStyle == .delete { + objects.remove(at: indexPath.row) + tableView.deleteRows(at: [indexPath], with: .fade) + } else if editingStyle == .insert { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. + } + } + + +} + +extension MasterViewController { + fileprivate func setupNotificationObservers() { + NotificationCenter.default.addObserver(self, selector: #selector(reloadTableView(_:)), name: .dataRetrieved, object: nil) + } + + fileprivate func removeNotificationObserver() { + NotificationCenter.default.removeObserver(self, name: .dataRetrieved, object: nil) + } + + @objc fileprivate func reloadTableView(_ notification: Notification) { + DispatchQueue.main.async { [unowned self] in + + print("====",self.dreams) + self.tableView.reloadData() + } + } + + var dreams : [Dream] { + return ApplicationData.DatabaseData.read() + } +} + + diff --git a/swiftdemo/swift01/swift01/Model/Dream.swift b/swiftdemo/swift01/swift01/Model/Dream.swift new file mode 100644 index 0000000000000000000000000000000000000000..fb20c1fa77677454998fb80302e38d3db5c04b0a --- /dev/null +++ b/swiftdemo/swift01/swift01/Model/Dream.swift @@ -0,0 +1,16 @@ +// +// Dream.swift +// swift01 +// +// Created by on 2020/8/19. +// Copyright © 2020 admin. All rights reserved. +// + +import Foundation + +struct Dream { + var title: String + var dateString: String + var tags: [String] + var description: String +} diff --git a/swiftdemo/swift01/swift01/Model/DreamData.swift b/swiftdemo/swift01/swift01/Model/DreamData.swift new file mode 100644 index 0000000000000000000000000000000000000000..04d446f671c0446863f51bfe9b79c93db0b66e66 --- /dev/null +++ b/swiftdemo/swift01/swift01/Model/DreamData.swift @@ -0,0 +1,27 @@ +// +// DreamData.swift +// swift01 +// +// Created by on 2020/8/19. +// Copyright © 2020 admin. All rights reserved. +// + +import Foundation + +struct DreamData { + var data = [Dream]() +} + +extension DreamData { + func write(toData data: Dream) { + ApplicationData.DatabaseData.data.append(data) + } + + func read() -> [Dream] { + return ApplicationData.DatabaseData.data + } +} + +class ApplicationData { + static var DatabaseData = DreamData() +} diff --git a/swiftdemo/swift01/swift01/NotificationName_Ext.swift b/swiftdemo/swift01/swift01/NotificationName_Ext.swift new file mode 100644 index 0000000000000000000000000000000000000000..6092393052fa73fcae80890c89deadd4696da2e8 --- /dev/null +++ b/swiftdemo/swift01/swift01/NotificationName_Ext.swift @@ -0,0 +1,13 @@ +// +// NotificationName_Ext.swift +// swift01 +// +// Created by on 2020/8/19. +// Copyright © 2020 admin. All rights reserved. +// + +import Foundation + +extension Notification.Name { + static let dataRetrieved = Notification.Name("dataRetrieved") +} diff --git a/swiftdemo/swift01/swift01/Resource.swift b/swiftdemo/swift01/swift01/Resource.swift new file mode 100644 index 0000000000000000000000000000000000000000..6cc1835e02f84f9f7540dbfc55a9903804fae7b3 --- /dev/null +++ b/swiftdemo/swift01/swift01/Resource.swift @@ -0,0 +1,27 @@ +// +// Resource.swift +// swift01 +// +// Created by on 2020/8/18. +// Copyright © 2020 admin. All rights reserved. +// + +import Foundation + +struct Resource { + let url: URL + let parse: (Data) -> T? +} + +extension Resource where T: Decodable { + init(_ url: URL, parseJSON: @escaping (Data) -> T?) { + self.url = url +// self.parse = { data in +// let decoder = JSONDecoder() +// let object = try? decoder.decode(T.self, from: data) +// return object +// } + self.parse = parseJSON + } +} + diff --git a/swiftdemo/swift01/swift01/SceneDelegate.swift b/swiftdemo/swift01/swift01/SceneDelegate.swift new file mode 100644 index 0000000000000000000000000000000000000000..beec1f8ec073dde4784b657647014ba6bea92ffc --- /dev/null +++ b/swiftdemo/swift01/swift01/SceneDelegate.swift @@ -0,0 +1,69 @@ +// +// SceneDelegate.swift +// swift01 +// +// Created by on 2020/8/18. +// Copyright © 2020 admin. All rights reserved. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate, UISplitViewControllerDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let window = window else { return } + guard let splitViewController = window.rootViewController as? UISplitViewController else { return } + guard let navigationController = splitViewController.viewControllers.last as? UINavigationController else { return } + navigationController.topViewController?.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem + navigationController.topViewController?.navigationItem.leftItemsSupplementBackButton = true + splitViewController.delegate = self + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + // MARK: - Split view + + func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController:UIViewController, onto primaryViewController:UIViewController) -> Bool { + guard let secondaryAsNavController = secondaryViewController as? UINavigationController else { return false } + guard let topAsDetailController = secondaryAsNavController.topViewController as? DetailViewController else { return false } + if topAsDetailController.detailItem == nil { + // Return true to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded. + return true + } + return false + } + +} + diff --git a/swiftdemo/swift01/swift01/Util/DateFmt.swift b/swiftdemo/swift01/swift01/Util/DateFmt.swift new file mode 100644 index 0000000000000000000000000000000000000000..a0913eda7cd8c5996af6812d189c6c7f95d0ae9c --- /dev/null +++ b/swiftdemo/swift01/swift01/Util/DateFmt.swift @@ -0,0 +1,19 @@ +// +// DateFmt.swift +// swift01 +// +// Created by on 2020/8/18. +// Copyright © 2020 admin. All rights reserved. +// + +import Foundation + +struct DateFmt { + let dateString: String + + init(date: Date) { + let formatter = DateFormatter() + formatter.dateFormat = "d MMM yyyy" + dateString = formatter.string(from: date) + } +} diff --git a/swiftdemo/swift01/swift01/Util/RandomNumberGenerator.swift b/swiftdemo/swift01/swift01/Util/RandomNumberGenerator.swift new file mode 100644 index 0000000000000000000000000000000000000000..6520d77d337c1dd97e3e8866972662ae995fc9f6 --- /dev/null +++ b/swiftdemo/swift01/swift01/Util/RandomNumberGenerator.swift @@ -0,0 +1,19 @@ +// +// RandomNumberGenerator.swift +// swift01 +// +// Created by on 2020/8/19. +// Copyright © 2020 admin. All rights reserved. +// + +import Foundation +import GameplayKit + +struct RandomNumberGenerator { + fileprivate let source = GKRandomSource.sharedRandom() + + public func getRandomNumber(withUpperBound bound: Int) -> Double { + let randomSource = source.nextInt(upperBound: bound) + return Double(randomSource) + } +} diff --git a/swiftdemo/swift01/swift01/WebService.swift b/swiftdemo/swift01/swift01/WebService.swift new file mode 100644 index 0000000000000000000000000000000000000000..3ab16c6062ec951529124db6b565f334fb960748 --- /dev/null +++ b/swiftdemo/swift01/swift01/WebService.swift @@ -0,0 +1,36 @@ +// +// WebService.swift +// swift01 +// +// Created by on 2020/8/19. +// Copyright © 2020 admin. All rights reserved. +// + +import Foundation + +final class WebService { + func load(resource: Resource, completion:@escaping(T?)->Void) { + URLSession.shared.dataTask(with: resource.url) { + (receivedData, _, error) in + if let error = error { + print(error.localizedDescription) + return; + } + guard let data = receivedData else {return completion(nil)} + completion(resource.parse(data)) + }.resume() + } +} + + + + + + + + + + + + +