commit 829b866ff8380f51df4e3cef9c3547cbf178c2ed Author: Marco Schmickler Date: Sun May 24 20:18:19 2015 +0200 Initial Commit diff --git a/kplayer.xcodeproj/project.pbxproj b/kplayer.xcodeproj/project.pbxproj new file mode 100644 index 0000000..9fc6752 --- /dev/null +++ b/kplayer.xcodeproj/project.pbxproj @@ -0,0 +1,447 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + C98AF5D51B124D6A00D196CC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98AF5D41B124D6A00D196CC /* AppDelegate.swift */; }; + C98AF5D81B124D6A00D196CC /* kplayer.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = C98AF5D61B124D6A00D196CC /* kplayer.xcdatamodeld */; }; + C98AF5DA1B124D6A00D196CC /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98AF5D91B124D6A00D196CC /* MasterViewController.swift */; }; + C98AF5DC1B124D6A00D196CC /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98AF5DB1B124D6A00D196CC /* DetailViewController.swift */; }; + C98AF5DF1B124D6A00D196CC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C98AF5DD1B124D6A00D196CC /* Main.storyboard */; }; + C98AF5E11B124D6A00D196CC /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C98AF5E01B124D6A00D196CC /* Images.xcassets */; }; + C98AF5E41B124D6A00D196CC /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = C98AF5E21B124D6A00D196CC /* LaunchScreen.xib */; }; + C98AF5F01B124D6A00D196CC /* kplayerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98AF5EF1B124D6A00D196CC /* kplayerTests.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + C98AF5EA1B124D6A00D196CC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C98AF5C71B124D6A00D196CC /* Project object */; + proxyType = 1; + remoteGlobalIDString = C98AF5CE1B124D6A00D196CC; + remoteInfo = kplayer; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + C98AF5CF1B124D6A00D196CC /* kplayer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = kplayer.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C98AF5D31B124D6A00D196CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C98AF5D41B124D6A00D196CC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + C98AF5D71B124D6A00D196CC /* kplayer.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = kplayer.xcdatamodel; sourceTree = ""; }; + C98AF5D91B124D6A00D196CC /* MasterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterViewController.swift; sourceTree = ""; }; + C98AF5DB1B124D6A00D196CC /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = ""; }; + C98AF5DE1B124D6A00D196CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + C98AF5E01B124D6A00D196CC /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + C98AF5E31B124D6A00D196CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; + C98AF5E91B124D6A00D196CC /* kplayerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = kplayerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + C98AF5EE1B124D6A00D196CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C98AF5EF1B124D6A00D196CC /* kplayerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = kplayerTests.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + C98AF5CC1B124D6A00D196CC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C98AF5E61B124D6A00D196CC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C98AF5C61B124D6A00D196CC = { + isa = PBXGroup; + children = ( + C98AF5D11B124D6A00D196CC /* kplayer */, + C98AF5EC1B124D6A00D196CC /* kplayerTests */, + C98AF5D01B124D6A00D196CC /* Products */, + ); + sourceTree = ""; + }; + C98AF5D01B124D6A00D196CC /* Products */ = { + isa = PBXGroup; + children = ( + C98AF5CF1B124D6A00D196CC /* kplayer.app */, + C98AF5E91B124D6A00D196CC /* kplayerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + C98AF5D11B124D6A00D196CC /* kplayer */ = { + isa = PBXGroup; + children = ( + C98AF5D41B124D6A00D196CC /* AppDelegate.swift */, + C98AF5D91B124D6A00D196CC /* MasterViewController.swift */, + C98AF5DB1B124D6A00D196CC /* DetailViewController.swift */, + C98AF5DD1B124D6A00D196CC /* Main.storyboard */, + C98AF5E01B124D6A00D196CC /* Images.xcassets */, + C98AF5E21B124D6A00D196CC /* LaunchScreen.xib */, + C98AF5D61B124D6A00D196CC /* kplayer.xcdatamodeld */, + C98AF5D21B124D6A00D196CC /* Supporting Files */, + ); + path = kplayer; + sourceTree = ""; + }; + C98AF5D21B124D6A00D196CC /* Supporting Files */ = { + isa = PBXGroup; + children = ( + C98AF5D31B124D6A00D196CC /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + C98AF5EC1B124D6A00D196CC /* kplayerTests */ = { + isa = PBXGroup; + children = ( + C98AF5EF1B124D6A00D196CC /* kplayerTests.swift */, + C98AF5ED1B124D6A00D196CC /* Supporting Files */, + ); + path = kplayerTests; + sourceTree = ""; + }; + C98AF5ED1B124D6A00D196CC /* Supporting Files */ = { + isa = PBXGroup; + children = ( + C98AF5EE1B124D6A00D196CC /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + C98AF5CE1B124D6A00D196CC /* kplayer */ = { + isa = PBXNativeTarget; + buildConfigurationList = C98AF5F31B124D6A00D196CC /* Build configuration list for PBXNativeTarget "kplayer" */; + buildPhases = ( + C98AF5CB1B124D6A00D196CC /* Sources */, + C98AF5CC1B124D6A00D196CC /* Frameworks */, + C98AF5CD1B124D6A00D196CC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = kplayer; + productName = kplayer; + productReference = C98AF5CF1B124D6A00D196CC /* kplayer.app */; + productType = "com.apple.product-type.application"; + }; + C98AF5E81B124D6A00D196CC /* kplayerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = C98AF5F61B124D6A00D196CC /* Build configuration list for PBXNativeTarget "kplayerTests" */; + buildPhases = ( + C98AF5E51B124D6A00D196CC /* Sources */, + C98AF5E61B124D6A00D196CC /* Frameworks */, + C98AF5E71B124D6A00D196CC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + C98AF5EB1B124D6A00D196CC /* PBXTargetDependency */, + ); + name = kplayerTests; + productName = kplayerTests; + productReference = C98AF5E91B124D6A00D196CC /* kplayerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + C98AF5C71B124D6A00D196CC /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0630; + ORGANIZATIONNAME = "Marco Schmickler"; + TargetAttributes = { + C98AF5CE1B124D6A00D196CC = { + CreatedOnToolsVersion = 6.3.1; + }; + C98AF5E81B124D6A00D196CC = { + CreatedOnToolsVersion = 6.3.1; + TestTargetID = C98AF5CE1B124D6A00D196CC; + }; + }; + }; + buildConfigurationList = C98AF5CA1B124D6A00D196CC /* Build configuration list for PBXProject "kplayer" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = C98AF5C61B124D6A00D196CC; + productRefGroup = C98AF5D01B124D6A00D196CC /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C98AF5CE1B124D6A00D196CC /* kplayer */, + C98AF5E81B124D6A00D196CC /* kplayerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + C98AF5CD1B124D6A00D196CC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C98AF5DF1B124D6A00D196CC /* Main.storyboard in Resources */, + C98AF5E41B124D6A00D196CC /* LaunchScreen.xib in Resources */, + C98AF5E11B124D6A00D196CC /* Images.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C98AF5E71B124D6A00D196CC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C98AF5CB1B124D6A00D196CC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C98AF5D81B124D6A00D196CC /* kplayer.xcdatamodeld in Sources */, + C98AF5D51B124D6A00D196CC /* AppDelegate.swift in Sources */, + C98AF5DA1B124D6A00D196CC /* MasterViewController.swift in Sources */, + C98AF5DC1B124D6A00D196CC /* DetailViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + C98AF5E51B124D6A00D196CC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C98AF5F01B124D6A00D196CC /* kplayerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + C98AF5EB1B124D6A00D196CC /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C98AF5CE1B124D6A00D196CC /* kplayer */; + targetProxy = C98AF5EA1B124D6A00D196CC /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + C98AF5DD1B124D6A00D196CC /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + C98AF5DE1B124D6A00D196CC /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + C98AF5E21B124D6A00D196CC /* LaunchScreen.xib */ = { + isa = PBXVariantGroup; + children = ( + C98AF5E31B124D6A00D196CC /* Base */, + ); + name = LaunchScreen.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + C98AF5F11B124D6A00D196CC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + 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 = 8.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + C98AF5F21B124D6A00D196CC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "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 = gnu99; + 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 = 8.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + C98AF5F41B124D6A00D196CC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = kplayer/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + C98AF5F51B124D6A00D196CC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = kplayer/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + C98AF5F71B124D6A00D196CC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = kplayerTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/kplayer.app/kplayer"; + }; + name = Debug; + }; + C98AF5F81B124D6A00D196CC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + INFOPLIST_FILE = kplayerTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/kplayer.app/kplayer"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C98AF5CA1B124D6A00D196CC /* Build configuration list for PBXProject "kplayer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C98AF5F11B124D6A00D196CC /* Debug */, + C98AF5F21B124D6A00D196CC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C98AF5F31B124D6A00D196CC /* Build configuration list for PBXNativeTarget "kplayer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C98AF5F41B124D6A00D196CC /* Debug */, + C98AF5F51B124D6A00D196CC /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; + C98AF5F61B124D6A00D196CC /* Build configuration list for PBXNativeTarget "kplayerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C98AF5F71B124D6A00D196CC /* Debug */, + C98AF5F81B124D6A00D196CC /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + +/* Begin XCVersionGroup section */ + C98AF5D61B124D6A00D196CC /* kplayer.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + C98AF5D71B124D6A00D196CC /* kplayer.xcdatamodel */, + ); + currentVersion = C98AF5D71B124D6A00D196CC /* kplayer.xcdatamodel */; + path = kplayer.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ + }; + rootObject = C98AF5C71B124D6A00D196CC /* Project object */; +} diff --git a/kplayer.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/kplayer.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..e4f3f32 --- /dev/null +++ b/kplayer.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/kplayer/AppDelegate.swift b/kplayer/AppDelegate.swift new file mode 100644 index 0000000..a76d230 --- /dev/null +++ b/kplayer/AppDelegate.swift @@ -0,0 +1,132 @@ +// +// AppDelegate.swift +// kplayer +// +// Created by Marco Schmickler on 24.05.15. +// Copyright (c) 2015 Marco Schmickler. All rights reserved. +// + +import UIKit +import CoreData + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate { + + var window: UIWindow? + + + func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + // Override point for customization after application launch. + let splitViewController = self.window!.rootViewController as! UISplitViewController + let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController + navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem() + splitViewController.delegate = self + + let masterNavigationController = splitViewController.viewControllers[0] as! UINavigationController + let controller = masterNavigationController.topViewController as! MasterViewController + controller.managedObjectContext = self.managedObjectContext + return true + } + + func applicationWillResignActive(application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(application: UIApplication) { + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + // Saves changes in the application's managed object context before the application terminates. + self.saveContext() + } + + // MARK: - Split view + + func splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController:UIViewController!, ontoPrimaryViewController primaryViewController:UIViewController!) -> Bool { + if let secondaryAsNavController = secondaryViewController as? UINavigationController { + if let topAsDetailController = secondaryAsNavController.topViewController as? DetailViewController { + 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 + } + // MARK: - Core Data stack + + lazy var applicationDocumentsDirectory: NSURL = { + // The directory the application uses to store the Core Data store file. This code uses a directory named "schmickler.kplayer" in the application's documents Application Support directory. + let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask) + return urls[urls.count-1] as! NSURL + }() + + lazy var managedObjectModel: NSManagedObjectModel = { + // The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model. + let modelURL = NSBundle.mainBundle().URLForResource("kplayer", withExtension: "momd")! + return NSManagedObjectModel(contentsOfURL: modelURL)! + }() + + lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = { + // The persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail. + // Create the coordinator and store + var coordinator: NSPersistentStoreCoordinator? = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel) + let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("kplayer.sqlite") + var error: NSError? = nil + var failureReason = "There was an error creating or loading the application's saved data." + if coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil, error: &error) == nil { + coordinator = nil + // Report any error we got. + var dict = [String: AnyObject]() + dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data" + dict[NSLocalizedFailureReasonErrorKey] = failureReason + dict[NSUnderlyingErrorKey] = error + error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict) + // Replace this with code to handle the error appropriately. + // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. + NSLog("Unresolved error \(error), \(error!.userInfo)") + abort() + } + + return coordinator + }() + + lazy var managedObjectContext: NSManagedObjectContext? = { + // Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) This property is optional since there are legitimate error conditions that could cause the creation of the context to fail. + let coordinator = self.persistentStoreCoordinator + if coordinator == nil { + return nil + } + var managedObjectContext = NSManagedObjectContext() + managedObjectContext.persistentStoreCoordinator = coordinator + return managedObjectContext + }() + + // MARK: - Core Data Saving support + + func saveContext () { + if let moc = self.managedObjectContext { + var error: NSError? = nil + if moc.hasChanges && !moc.save(&error) { + // Replace this implementation with code to handle the error appropriately. + // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. + NSLog("Unresolved error \(error), \(error!.userInfo)") + abort() + } + } + } + +} + diff --git a/kplayer/Base.lproj/LaunchScreen.xib b/kplayer/Base.lproj/LaunchScreen.xib new file mode 100644 index 0000000..338a293 --- /dev/null +++ b/kplayer/Base.lproj/LaunchScreen.xib @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kplayer/Base.lproj/Main.storyboard b/kplayer/Base.lproj/Main.storyboard new file mode 100644 index 0000000..b3b5a78 --- /dev/null +++ b/kplayer/Base.lproj/Main.storyboard @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kplayer/DetailViewController.swift b/kplayer/DetailViewController.swift new file mode 100644 index 0000000..09f284f --- /dev/null +++ b/kplayer/DetailViewController.swift @@ -0,0 +1,45 @@ +// +// DetailViewController.swift +// kplayer +// +// Created by Marco Schmickler on 24.05.15. +// Copyright (c) 2015 Marco Schmickler. All rights reserved. +// + +import UIKit + +class DetailViewController: UIViewController { + + @IBOutlet weak var detailDescriptionLabel: UILabel! + + + var detailItem: AnyObject? { + didSet { + // Update the view. + self.configureView() + } + } + + func configureView() { + // Update the user interface for the detail item. + if let detail: AnyObject = self.detailItem { + if let label = self.detailDescriptionLabel { + label.text = detail.valueForKey("timeStamp")!.description + } + } + } + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + self.configureView() + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + +} + diff --git a/kplayer/Images.xcassets/AppIcon.appiconset/Contents.json b/kplayer/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..36d2c80 --- /dev/null +++ b/kplayer/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "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" : "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" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/kplayer/Info.plist b/kplayer/Info.plist new file mode 100644 index 0000000..1f75b9f --- /dev/null +++ b/kplayer/Info.plist @@ -0,0 +1,57 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + schmickler.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UIStatusBarTintParameters + + UINavigationBar + + Style + UIBarStyleDefault + Translucent + + + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/kplayer/MasterViewController.swift b/kplayer/MasterViewController.swift new file mode 100644 index 0000000..fcc2deb --- /dev/null +++ b/kplayer/MasterViewController.swift @@ -0,0 +1,203 @@ +// +// MasterViewController.swift +// kplayer +// +// Created by Marco Schmickler on 24.05.15. +// Copyright (c) 2015 Marco Schmickler. All rights reserved. +// + +import UIKit +import CoreData + +class MasterViewController: UITableViewController, NSFetchedResultsControllerDelegate { + + var detailViewController: DetailViewController? = nil + var managedObjectContext: NSManagedObjectContext? = nil + + + override func awakeFromNib() { + super.awakeFromNib() + if UIDevice.currentDevice().userInterfaceIdiom == .Pad { + self.clearsSelectionOnViewWillAppear = false + self.preferredContentSize = CGSize(width: 320.0, height: 600.0) + } + } + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + self.navigationItem.leftBarButtonItem = self.editButtonItem() + + let addButton = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "insertNewObject:") + self.navigationItem.rightBarButtonItem = addButton + if let split = self.splitViewController { + let controllers = split.viewControllers + self.detailViewController = controllers[controllers.count-1].topViewController as? DetailViewController + } + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + func insertNewObject(sender: AnyObject) { + let context = self.fetchedResultsController.managedObjectContext + let entity = self.fetchedResultsController.fetchRequest.entity! + let newManagedObject = NSEntityDescription.insertNewObjectForEntityForName(entity.name!, inManagedObjectContext: context) as! NSManagedObject + + // If appropriate, configure the new managed object. + // Normally you should use accessor methods, but using KVC here avoids the need to add a custom class to the template. + newManagedObject.setValue(NSDate(), forKey: "timeStamp") + + // Save the context. + var error: NSError? = nil + if !context.save(&error) { + // Replace this implementation with code to handle the error appropriately. + // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. + //println("Unresolved error \(error), \(error.userInfo)") + abort() + } + } + + // MARK: - Segues + + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + if segue.identifier == "showDetail" { + if let indexPath = self.tableView.indexPathForSelectedRow() { + let object = self.fetchedResultsController.objectAtIndexPath(indexPath) as! NSManagedObject + let controller = (segue.destinationViewController as! UINavigationController).topViewController as! DetailViewController + controller.detailItem = object + controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem() + controller.navigationItem.leftItemsSupplementBackButton = true + } + } + } + + // MARK: - Table View + + override func numberOfSectionsInTableView(tableView: UITableView) -> Int { + return self.fetchedResultsController.sections?.count ?? 0 + } + + override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + let sectionInfo = self.fetchedResultsController.sections![section] as! NSFetchedResultsSectionInfo + return sectionInfo.numberOfObjects + } + + override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell + self.configureCell(cell, atIndexPath: indexPath) + return cell + } + + override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { + // Return false if you do not want the specified item to be editable. + return true + } + + override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { + if editingStyle == .Delete { + let context = self.fetchedResultsController.managedObjectContext + context.deleteObject(self.fetchedResultsController.objectAtIndexPath(indexPath) as! NSManagedObject) + + var error: NSError? = nil + if !context.save(&error) { + // Replace this implementation with code to handle the error appropriately. + // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. + //println("Unresolved error \(error), \(error.userInfo)") + abort() + } + } + } + + func configureCell(cell: UITableViewCell, atIndexPath indexPath: NSIndexPath) { + let object = self.fetchedResultsController.objectAtIndexPath(indexPath) as! NSManagedObject + cell.textLabel!.text = object.valueForKey("timeStamp")!.description + } + + // MARK: - Fetched results controller + + var fetchedResultsController: NSFetchedResultsController { + if _fetchedResultsController != nil { + return _fetchedResultsController! + } + + let fetchRequest = NSFetchRequest() + // Edit the entity name as appropriate. + let entity = NSEntityDescription.entityForName("Event", inManagedObjectContext: self.managedObjectContext!) + fetchRequest.entity = entity + + // Set the batch size to a suitable number. + fetchRequest.fetchBatchSize = 20 + + // Edit the sort key as appropriate. + let sortDescriptor = NSSortDescriptor(key: "timeStamp", ascending: false) + let sortDescriptors = [sortDescriptor] + + fetchRequest.sortDescriptors = [sortDescriptor] + + // Edit the section name key path and cache name if appropriate. + // nil for section name key path means "no sections". + let aFetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.managedObjectContext!, sectionNameKeyPath: nil, cacheName: "Master") + aFetchedResultsController.delegate = self + _fetchedResultsController = aFetchedResultsController + + var error: NSError? = nil + if !_fetchedResultsController!.performFetch(&error) { + // Replace this implementation with code to handle the error appropriately. + // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. + //println("Unresolved error \(error), \(error.userInfo)") + abort() + } + + return _fetchedResultsController! + } + var _fetchedResultsController: NSFetchedResultsController? = nil + + func controllerWillChangeContent(controller: NSFetchedResultsController) { + self.tableView.beginUpdates() + } + + func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) { + switch type { + case .Insert: + self.tableView.insertSections(NSIndexSet(index: sectionIndex), withRowAnimation: .Fade) + case .Delete: + self.tableView.deleteSections(NSIndexSet(index: sectionIndex), withRowAnimation: .Fade) + default: + return + } + } + + func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) { + switch type { + case .Insert: + tableView.insertRowsAtIndexPaths([newIndexPath!], withRowAnimation: .Fade) + case .Delete: + tableView.deleteRowsAtIndexPaths([indexPath!], withRowAnimation: .Fade) + case .Update: + self.configureCell(tableView.cellForRowAtIndexPath(indexPath!)!, atIndexPath: indexPath!) + case .Move: + tableView.deleteRowsAtIndexPaths([indexPath!], withRowAnimation: .Fade) + tableView.insertRowsAtIndexPaths([newIndexPath!], withRowAnimation: .Fade) + default: + return + } + } + + func controllerDidChangeContent(controller: NSFetchedResultsController) { + self.tableView.endUpdates() + } + + /* + // Implementing the above methods to update the table view in response to individual changes may have performance implications if a large number of changes are made simultaneously. If this proves to be an issue, you can instead just implement controllerDidChangeContent: which notifies the delegate that all section and object changes have been processed. + + func controllerDidChangeContent(controller: NSFetchedResultsController) { + // In the simplest, most efficient, case, reload the table view. + self.tableView.reloadData() + } + */ + +} + diff --git a/kplayer/kplayer.xcdatamodeld/.xccurrentversion b/kplayer/kplayer.xcdatamodeld/.xccurrentversion new file mode 100644 index 0000000..79a3f68 --- /dev/null +++ b/kplayer/kplayer.xcdatamodeld/.xccurrentversion @@ -0,0 +1,8 @@ + + + + + _XCCurrentVersionName + kplayer.xcdatamodel + + diff --git a/kplayer/kplayer.xcdatamodeld/kplayer.xcdatamodel/contents b/kplayer/kplayer.xcdatamodeld/kplayer.xcdatamodel/contents new file mode 100644 index 0000000..75b533a --- /dev/null +++ b/kplayer/kplayer.xcdatamodeld/kplayer.xcdatamodel/contents @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/kplayerTests/Info.plist b/kplayerTests/Info.plist new file mode 100644 index 0000000..0074743 --- /dev/null +++ b/kplayerTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + schmickler.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/kplayerTests/kplayerTests.swift b/kplayerTests/kplayerTests.swift new file mode 100644 index 0000000..a19d59e --- /dev/null +++ b/kplayerTests/kplayerTests.swift @@ -0,0 +1,36 @@ +// +// kplayerTests.swift +// kplayerTests +// +// Created by Marco Schmickler on 24.05.15. +// Copyright (c) 2015 Marco Schmickler. All rights reserved. +// + +import UIKit +import XCTest + +class kplayerTests: XCTestCase { + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testExample() { + // This is an example of a functional test case. + XCTAssert(true, "Pass") + } + + func testPerformanceExample() { + // This is an example of a performance test case. + self.measureBlock() { + // Put the code you want to measure the time of here. + } + } + +}