From 60b5733bf6245d86cde95404f6cbd14a9ca980b0 Mon Sep 17 00:00:00 2001 From: Uladzislau Abramchuk Date: Wed, 21 Feb 2018 14:50:08 +0300 Subject: [PATCH] first part --- .../WoWiLLIDANtASK.xcodeproj/project.pbxproj | 377 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../WoWiLLIDANtASK/FileManager/FileManager.h | 16 + .../WoWiLLIDANtASK/FileManager/FileManager.m | 61 +++ WoWiLLIDANtASK/WoWiLLIDANtASK/Info.plist | 45 +++ .../StarShipView/Base.lproj/Main.storyboard | 44 ++ .../StarShipView/ViewController.h | 15 + .../StarShipView/ViewController.m | 68 ++++ .../StrarShipInterface/StarShip.h | 25 ++ .../StrarShipInterface/StarShip.m | 43 ++ .../StrarShipInterface/StarShipsManager.h | 21 + .../StrarShipInterface/StarShipsManager.m | 136 +++++++ .../SupportingFiles/AppDelegate.h | 17 + .../SupportingFiles/AppDelegate.m | 24 ++ .../AppIcon.appiconset/Contents.json | 93 +++++ .../Base.lproj/LaunchScreen.storyboard | 25 ++ .../WoWiLLIDANtASK/SupportingFiles/main.m | 16 + 17 files changed, 1033 insertions(+) create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK.xcodeproj/project.pbxproj create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/FileManager/FileManager.h create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/FileManager/FileManager.m create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/Info.plist create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/StarShipView/Base.lproj/Main.storyboard create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/StarShipView/ViewController.h create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/StarShipView/ViewController.m create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShip.h create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShip.m create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShipsManager.h create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShipsManager.m create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/AppDelegate.h create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/AppDelegate.m create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/Base.lproj/LaunchScreen.storyboard create mode 100644 WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/main.m diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK.xcodeproj/project.pbxproj b/WoWiLLIDANtASK/WoWiLLIDANtASK.xcodeproj/project.pbxproj new file mode 100644 index 0000000..8f365be --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK.xcodeproj/project.pbxproj @@ -0,0 +1,377 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + objects = { + +/* Begin PBXBuildFile section */ + 04B49B542039E4C800204110 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 04B49B532039E4C800204110 /* AppDelegate.m */; }; + 04B49B572039E4C800204110 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04B49B562039E4C800204110 /* ViewController.m */; }; + 04B49B5A2039E4C800204110 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 04B49B582039E4C800204110 /* Main.storyboard */; }; + 04B49B5C2039E4C800204110 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 04B49B5B2039E4C800204110 /* Assets.xcassets */; }; + 04B49B5F2039E4C900204110 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 04B49B5D2039E4C900204110 /* LaunchScreen.storyboard */; }; + 04B49B622039E4C900204110 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 04B49B612039E4C900204110 /* main.m */; }; + 04B49BDF203A063300204110 /* StarShipsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 04B49BDE203A063300204110 /* StarShipsManager.m */; }; + 04B49BE2203A1F2300204110 /* StarShip.m in Sources */ = {isa = PBXBuildFile; fileRef = 04B49BE1203A1F2300204110 /* StarShip.m */; }; + 04DCD9DD203C54F2007BD790 /* FileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 04DCD9DC203C54F2007BD790 /* FileManager.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 04B49B4F2039E4C800204110 /* WoWiLLIDANtASK.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WoWiLLIDANtASK.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 04B49B522039E4C800204110 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 04B49B532039E4C800204110 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 04B49B552039E4C800204110 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 04B49B562039E4C800204110 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 04B49B592039E4C800204110 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 04B49B5B2039E4C800204110 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 04B49B5E2039E4C900204110 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 04B49B602039E4C900204110 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 04B49B612039E4C900204110 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 04B49BDD203A063300204110 /* StarShipsManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StarShipsManager.h; sourceTree = ""; }; + 04B49BDE203A063300204110 /* StarShipsManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StarShipsManager.m; sourceTree = ""; }; + 04B49BE0203A1F2300204110 /* StarShip.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StarShip.h; sourceTree = ""; }; + 04B49BE1203A1F2300204110 /* StarShip.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StarShip.m; sourceTree = ""; }; + 04DCD9DB203C54F2007BD790 /* FileManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FileManager.h; sourceTree = ""; }; + 04DCD9DC203C54F2007BD790 /* FileManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FileManager.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 04B49B4C2039E4C800204110 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 047174EA203D882A0083B463 /* StarShipView */ = { + isa = PBXGroup; + children = ( + 04B49B582039E4C800204110 /* Main.storyboard */, + 04B49B552039E4C800204110 /* ViewController.h */, + 04B49B562039E4C800204110 /* ViewController.m */, + ); + path = StarShipView; + sourceTree = ""; + }; + 047174EB203D888B0083B463 /* SupportingFiles */ = { + isa = PBXGroup; + children = ( + 04B49B522039E4C800204110 /* AppDelegate.h */, + 04B49B532039E4C800204110 /* AppDelegate.m */, + 04B49B5B2039E4C800204110 /* Assets.xcassets */, + 04B49B5D2039E4C900204110 /* LaunchScreen.storyboard */, + 04B49B612039E4C900204110 /* main.m */, + ); + path = SupportingFiles; + sourceTree = ""; + }; + 04B49B462039E4C800204110 = { + isa = PBXGroup; + children = ( + 04B49B512039E4C800204110 /* WoWiLLIDANtASK */, + 04B49B502039E4C800204110 /* Products */, + ); + sourceTree = ""; + }; + 04B49B502039E4C800204110 /* Products */ = { + isa = PBXGroup; + children = ( + 04B49B4F2039E4C800204110 /* WoWiLLIDANtASK.app */, + ); + name = Products; + sourceTree = ""; + }; + 04B49B512039E4C800204110 /* WoWiLLIDANtASK */ = { + isa = PBXGroup; + children = ( + 047174EB203D888B0083B463 /* SupportingFiles */, + 047174EA203D882A0083B463 /* StarShipView */, + 04DCD9DA203C54E2007BD790 /* FileManager */, + 04B49B682039E8E100204110 /* StrarShipInterface */, + 04B49B602039E4C900204110 /* Info.plist */, + ); + path = WoWiLLIDANtASK; + sourceTree = ""; + }; + 04B49B682039E8E100204110 /* StrarShipInterface */ = { + isa = PBXGroup; + children = ( + 04B49BDD203A063300204110 /* StarShipsManager.h */, + 04B49BDE203A063300204110 /* StarShipsManager.m */, + 04B49BE0203A1F2300204110 /* StarShip.h */, + 04B49BE1203A1F2300204110 /* StarShip.m */, + ); + path = StrarShipInterface; + sourceTree = ""; + }; + 04DCD9DA203C54E2007BD790 /* FileManager */ = { + isa = PBXGroup; + children = ( + 04DCD9DB203C54F2007BD790 /* FileManager.h */, + 04DCD9DC203C54F2007BD790 /* FileManager.m */, + ); + path = FileManager; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 04B49B4E2039E4C800204110 /* WoWiLLIDANtASK */ = { + isa = PBXNativeTarget; + buildConfigurationList = 04B49B652039E4C900204110 /* Build configuration list for PBXNativeTarget "WoWiLLIDANtASK" */; + buildPhases = ( + 04B49B4B2039E4C800204110 /* Sources */, + 04B49B4C2039E4C800204110 /* Frameworks */, + 04B49B4D2039E4C800204110 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = WoWiLLIDANtASK; + productName = WoWiLLIDANtASK; + productReference = 04B49B4F2039E4C800204110 /* WoWiLLIDANtASK.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 04B49B472039E4C800204110 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0920; + ORGANIZATIONNAME = "Uladzislau Abramchuk"; + TargetAttributes = { + 04B49B4E2039E4C800204110 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 04B49B4A2039E4C800204110 /* Build configuration list for PBXProject "WoWiLLIDANtASK" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 04B49B462039E4C800204110; + productRefGroup = 04B49B502039E4C800204110 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 04B49B4E2039E4C800204110 /* WoWiLLIDANtASK */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 04B49B4D2039E4C800204110 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 04B49B5F2039E4C900204110 /* LaunchScreen.storyboard in Resources */, + 04B49B5C2039E4C800204110 /* Assets.xcassets in Resources */, + 04B49B5A2039E4C800204110 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 04B49B4B2039E4C800204110 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 04B49B572039E4C800204110 /* ViewController.m in Sources */, + 04B49BDF203A063300204110 /* StarShipsManager.m in Sources */, + 04B49B622039E4C900204110 /* main.m in Sources */, + 04B49B542039E4C800204110 /* AppDelegate.m in Sources */, + 04B49BE2203A1F2300204110 /* StarShip.m in Sources */, + 04DCD9DD203C54F2007BD790 /* FileManager.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 04B49B582039E4C800204110 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 04B49B592039E4C800204110 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 04B49B5D2039E4C900204110 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 04B49B5E2039E4C900204110 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 04B49B632039E4C900204110 /* 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_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = 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_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; + CODE_SIGN_IDENTITY = "iPhone Developer"; + 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 = 11.2; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 04B49B642039E4C900204110 /* 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_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = 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_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; + CODE_SIGN_IDENTITY = "iPhone Developer"; + 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 = 11.2; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 04B49B662039E4C900204110 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = WoWiLLIDANtASK/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = v.abr.svr.WoWiLLIDANtASK; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 04B49B672039E4C900204110 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = WoWiLLIDANtASK/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = v.abr.svr.WoWiLLIDANtASK; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 04B49B4A2039E4C800204110 /* Build configuration list for PBXProject "WoWiLLIDANtASK" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 04B49B632039E4C900204110 /* Debug */, + 04B49B642039E4C900204110 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 04B49B652039E4C900204110 /* Build configuration list for PBXNativeTarget "WoWiLLIDANtASK" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 04B49B662039E4C900204110 /* Debug */, + 04B49B672039E4C900204110 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 04B49B472039E4C800204110 /* Project object */; +} diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/WoWiLLIDANtASK/WoWiLLIDANtASK.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..0ab0517 --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/FileManager/FileManager.h b/WoWiLLIDANtASK/WoWiLLIDANtASK/FileManager/FileManager.h new file mode 100644 index 0000000..0242a69 --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/FileManager/FileManager.h @@ -0,0 +1,16 @@ +// +// FileManager.h +// WoWiLLIDANtASK +// +// Created by Uladzislau Abramchuk on 20.02.2018. +// Copyright © 2018 Uladzislau Abramchuk. All rights reserved. +// + +#import + +@interface FileManager : NSObject ++(void)writeStarShipsToJSON: (NSArray *)array; ++(NSMutableArray *)readFromJSON; ++(BOOL)isFileExist; + +@end diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/FileManager/FileManager.m b/WoWiLLIDANtASK/WoWiLLIDANtASK/FileManager/FileManager.m new file mode 100644 index 0000000..83a4184 --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/FileManager/FileManager.m @@ -0,0 +1,61 @@ +// +// FileManager.m +// WoWiLLIDANtASK +// +// Created by Uladzislau Abramchuk on 20.02.2018. +// Copyright © 2018 Uladzislau Abramchuk. All rights reserved. +// + +#import "FileManager.h" +#import "StarShip.h" + +@implementation FileManager ++(void)writeStarShipsToJSON:(NSArray *)array +{ + NSMutableArray *arr = [NSMutableArray array]; + for (StarShip *shp in array) { + [arr addObject:[shp toJSON]]; + } + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:arr options:NSJSONWritingPrettyPrinted error:nil]; + NSString* filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; + NSString* fileName = @"JSON.json"; + NSString* fileAtPath = [filePath stringByAppendingPathComponent:fileName]; + + if (![[NSFileManager defaultManager] fileExistsAtPath:fileAtPath]) { + [[NSFileManager defaultManager] createFileAtPath:fileAtPath contents:nil attributes:nil]; + } + + [jsonData writeToFile:fileAtPath atomically:NO]; +} + ++(NSMutableArray *)readFromJSON { + NSString* filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; + NSString* fileName = @"JSON.json"; + NSString* fileAtPath = [filePath stringByAppendingPathComponent:fileName]; + NSData *data = [NSData dataWithContentsOfFile:fileAtPath]; + + id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + NSMutableArray *arr = [NSMutableArray array]; + for (NSDictionary *dict in json) { + [arr addObject:[StarShip fromData:dict]]; + } + return arr; +} + + + + + ++(BOOL)isFileExist +{ + NSString* filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; + NSString* fileName = @"JSON.json"; + NSString* fileAtPath = [filePath stringByAppendingPathComponent:fileName]; + + if (![[NSFileManager defaultManager] fileExistsAtPath:fileAtPath]) { + return NO; + } + return YES; +} + +@end diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/Info.plist b/WoWiLLIDANtASK/WoWiLLIDANtASK/Info.plist new file mode 100644 index 0000000..16be3b6 --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/StarShipView/Base.lproj/Main.storyboard b/WoWiLLIDANtASK/WoWiLLIDANtASK/StarShipView/Base.lproj/Main.storyboard new file mode 100644 index 0000000..24b4f53 --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/StarShipView/Base.lproj/Main.storyboard @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/StarShipView/ViewController.h b/WoWiLLIDANtASK/WoWiLLIDANtASK/StarShipView/ViewController.h new file mode 100644 index 0000000..0aa627d --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/StarShipView/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// WoWiLLIDANtASK +// +// Created by Uladzislau Abramchuk on 18.02.2018. +// Copyright © 2018 Uladzislau Abramchuk. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/StarShipView/ViewController.m b/WoWiLLIDANtASK/WoWiLLIDANtASK/StarShipView/ViewController.m new file mode 100644 index 0000000..bc076a8 --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/StarShipView/ViewController.m @@ -0,0 +1,68 @@ +// +// ViewController.m +// WoWiLLIDANtASK +// +// Created by Uladzislau Abramchuk on 18.02.2018. +// Copyright © 2018 Uladzislau Abramchuk. All rights reserved. +// + +#import "ViewController.h" +#import "StarShipsManager.h" +#import "StarShip.h" + + +@interface ViewController () +@property (nonatomic, strong) NSArray *ships; +@property (weak, nonatomic) IBOutlet UITableView *tableView; + +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.tableView.delegate = self; + self.tableView.dataSource = self; + [StarShipsManager getStarShips:YES :^(NSArray *arr){ + self.ships = arr; + dispatch_async(dispatch_get_main_queue(), ^{ + [self.tableView reloadData]; + }); + }]; + +} + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} + +- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { + UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"rec"]; + StarShip *ship = self.ships[indexPath.section][indexPath.row]; + cell.detailTextLabel.text = ship.model; + cell.textLabel.text = ship.name; + return cell; +} + +-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section +{ + StarShip *ship = self.ships[section][0]; + return ship.starshipClass; +} + +- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + + return [(NSArray *)(self.ships[section]) count]; +} + +-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return self.ships.count; +} + + +@end + + + diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShip.h b/WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShip.h new file mode 100644 index 0000000..ae76c21 --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShip.h @@ -0,0 +1,25 @@ +// +// StarShip.h +// WoWiLLIDANtASK +// +// Created by Uladzislau Abramchuk on 18.02.2018. +// Copyright © 2018 Uladzislau Abramchuk. All rights reserved. +// + +#import + +@interface StarShip : NSObject +@property (nonatomic, copy) NSString *name; +@property (nonatomic, copy) NSString *model; +@property (nonatomic, copy) NSString *manufacturer; +@property (nonatomic, copy) NSString *costInCredits; +@property (nonatomic, copy) NSString *length; +@property (nonatomic, copy) NSString *maxAtmospheringSpeed; +@property (nonatomic, copy) NSString *crew; +@property (nonatomic, copy) NSString *passengers; +@property (nonatomic, copy) NSString *cargoCapacity; +@property (nonatomic, copy) NSString *consumables; +@property (nonatomic, copy) NSString *starshipClass; ++ (instancetype)fromData:(NSDictionary *)data; +- (NSDictionary *)toJSON; +@end diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShip.m b/WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShip.m new file mode 100644 index 0000000..272b1bc --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShip.m @@ -0,0 +1,43 @@ +// +// StarShip.m +// WoWiLLIDANtASK +// +// Created by Uladzislau Abramchuk on 18.02.2018. +// Copyright © 2018 Uladzislau Abramchuk. All rights reserved. +// + +#import "StarShip.h" + +@implementation StarShip +-(NSDictionary *)toJSON { + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: + self.name,@"name", + self.model,@"model", + self.manufacturer, @"manufacturer", + self.costInCredits, @"cost_in_credits", + self.length, @"length", + self.maxAtmospheringSpeed, @"max_atmosphering_speed", + self.crew, @"crew", + self.passengers, @"passengers", + self.cargoCapacity, @"cargo_capacity", + self.consumables, @"consumables", + self.starshipClass, @"starship_class", nil]; + return dict; +} ++ (instancetype)fromData:(NSDictionary *)data +{ + StarShip *ship = [[StarShip alloc] init]; + ship.name = data[@"name"]; + ship.model = data[@"model"]; + ship.manufacturer = data[@"manufacturer"]; + ship.costInCredits = data[@"cost_in_credits"]; + ship.length = data[@"length"]; + ship.maxAtmospheringSpeed = data[@"max_atmosphering_speed"]; + ship.crew = data[@"crew"]; + ship.passengers = data[@"passengers"]; + ship.cargoCapacity = data[@"cargo_capacity"]; + ship.consumables = data[@"consumables"]; + ship.starshipClass = data[@"starship_class"]; + return ship; +} +@end diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShipsManager.h b/WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShipsManager.h new file mode 100644 index 0000000..be79248 --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShipsManager.h @@ -0,0 +1,21 @@ +// +// StarShipsManager.h +// WoWiLLIDANtASK +// +// Created by Uladzislau Abramchuk on 18.02.2018. +// Copyright © 2018 Uladzislau Abramchuk. All rights reserved. +// + +#import +typedef void(^completion)(NSArray *); +@interface StarShipsManager : NSObject +@property (nonatomic, copy) NSNumber *count; +@property (nonatomic, copy) NSString *next; +@property (nonatomic, copy) NSString *previous; +@property (nonatomic, strong) NSMutableArray *ships; + ++ (void)getStarShips: (BOOL)isSorted : (completion) completionBlock; +//@property (nonatomic) NSArray *friends; +@end + + diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShipsManager.m b/WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShipsManager.m new file mode 100644 index 0000000..8c6e60c --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/StrarShipInterface/StarShipsManager.m @@ -0,0 +1,136 @@ +// +// StarShipsManager.m +// WoWiLLIDANtASK +// +// Created by Uladzislau Abramchuk on 18.02.2018. +// Copyright © 2018 Uladzislau Abramchuk. All rights reserved. +// + +#import "StarShipsManager.h" +#import "StarShip.h" +#import "FileManager.h" + + +@implementation StarShipsManager + ++ (void)getStarShips: (BOOL)isSorted : (completion)completionBlock +{ + // try to load from file + if ([FileManager isFileExist]){ + if (isSorted) { + NSArray *sortedArr = [StarShipsManager sortShipsByClass:[FileManager readFromJSON]]; + completionBlock(sortedArr); + }else { + completionBlock([FileManager readFromJSON]); + } + return; + } + + + NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://swapi.co/api/starships/"]]; + [urlRequest setHTTPMethod:@"GET"]; + NSURLSession *session = [NSURLSession sharedSession]; + NSURLSessionDataTask *dataTask = [session dataTaskWithRequest: + urlRequest completionHandler: + ^(NSData *data, NSURLResponse *response, NSError *error) + { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; + if(httpResponse.statusCode == 200) + { + id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + StarShipsManager *manager = [[StarShipsManager alloc] init]; + manager.count = json[@"count"]; + manager.previous = json[@"previous"]; + manager.next = json[@"next"]; + manager.ships = [NSMutableArray array]; + + for (NSDictionary *dict in json[@"results"]) { + StarShip *ship = [StarShip fromData:dict]; + [manager.ships addObject:ship]; + } + + [manager performQuery:manager.next :^(NSArray *arr) { + [manager.ships addObjectsFromArray:arr]; + [FileManager writeStarShipsToJSON:manager.ships]; + + if (isSorted) { + NSArray *sortedShips = [StarShipsManager sortShipsByClass:manager.ships]; + completionBlock(sortedShips); + }else { + completionBlock(manager.ships); + } + + }]; + [session invalidateAndCancel]; + } + }]; + [dataTask resume]; +} + +-(void)performQuery:(NSString *)next : (completion)completionBlock { + NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:next]]; + [urlRequest setHTTPMethod:@"GET"]; + NSURLSession *session = [NSURLSession sharedSession]; + NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:urlRequest completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) + { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; + if(httpResponse.statusCode == 200) + { + id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + StarShipsManager *manager = [[StarShipsManager alloc] init]; + manager.ships = [NSMutableArray array]; + for (NSDictionary *dict in json[@"results"]) { + StarShip *ship = [StarShip fromData:dict]; + [manager.ships addObject:ship]; + } + + + manager.next = json[@"next"]; + if (manager.next == (id)[NSNull null]) { + completionBlock(manager.ships); + [session invalidateAndCancel]; + return; + } + + + [manager performQuery:manager.next :^(NSArray *arr) { + [manager.ships addObjectsFromArray:arr]; + + completionBlock(manager.ships); + [session invalidateAndCancel]; + }]; + } + }]; + [dataTask resume]; +} + + + ++(NSArray *)sortShipsByClass: (NSArray *)arr +{ + NSMutableSet *sectionsName = [NSMutableSet set]; + for (StarShip *ship in arr) { + [sectionsName addObject:[ship.starshipClass lowercaseString]]; + } + NSMutableArray *shipsWithSections = [NSMutableArray array]; + + + + for (NSString *className in sectionsName) { + + NSMutableArray *ships = [NSMutableArray array]; + [shipsWithSections addObject:ships]; + + for (StarShip *starship in arr) { + + if ([[starship.starshipClass lowercaseString] isEqualToString:className]) { + [ships addObject:starship]; + } + } + } + return [shipsWithSections copy]; +} + + +@end + diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/AppDelegate.h b/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/AppDelegate.h new file mode 100644 index 0000000..4f3d8a9 --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// WoWiLLIDANtASK +// +// Created by Uladzislau Abramchuk on 18.02.2018. +// Copyright © 2018 Uladzislau Abramchuk. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/AppDelegate.m b/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/AppDelegate.m new file mode 100644 index 0000000..61370a2 --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/AppDelegate.m @@ -0,0 +1,24 @@ +// +// AppDelegate.m +// WoWiLLIDANtASK +// +// Created by Uladzislau Abramchuk on 18.02.2018. +// Copyright © 2018 Uladzislau Abramchuk. 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; +} + + +@end diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/Assets.xcassets/AppIcon.appiconset/Contents.json b/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..1d060ed --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,93 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/Base.lproj/LaunchScreen.storyboard b/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f83f6fd --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/main.m b/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/main.m new file mode 100644 index 0000000..6ee9792 --- /dev/null +++ b/WoWiLLIDANtASK/WoWiLLIDANtASK/SupportingFiles/main.m @@ -0,0 +1,16 @@ +// +// main.m +// WoWiLLIDANtASK +// +// Created by Uladzislau Abramchuk on 18.02.2018. +// Copyright © 2018 Uladzislau Abramchuk. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +}