Skip to content

Commit

Permalink
Updated to Swift 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Janusz Chudzynski committed Nov 17, 2015
1 parent 7ff9d8a commit 44ae1f0
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 166 deletions.
25 changes: 7 additions & 18 deletions JMCMarchingAnts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
4026614C1BE7F52400BF39D6 /* 038420-glossy-black-icon-transport-travel-transportation-car9-sc44.png in Resources */ = {isa = PBXBuildFile; fileRef = 4026614B1BE7F52400BF39D6 /* 038420-glossy-black-icon-transport-travel-transportation-car9-sc44.png */; };
4026614D1BE7F52400BF39D6 /* 038420-glossy-black-icon-transport-travel-transportation-car9-sc44.png in Resources */ = {isa = PBXBuildFile; fileRef = 4026614B1BE7F52400BF39D6 /* 038420-glossy-black-icon-transport-travel-transportation-car9-sc44.png */; };
4049CD7E1BC2D43F00F1E353 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4049CD7D1BC2D43F00F1E353 /* AppDelegate.swift */; };
4049CD811BC2D43F00F1E353 /* JMCMarchingAnts.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 4049CD7F1BC2D43F00F1E353 /* JMCMarchingAnts.xcdatamodeld */; };
4049CD831BC2D43F00F1E353 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4049CD821BC2D43F00F1E353 /* ViewController.swift */; };
4049CD861BC2D43F00F1E353 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4049CD841BC2D43F00F1E353 /* Main.storyboard */; };
4049CD881BC2D43F00F1E353 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4049CD871BC2D43F00F1E353 /* Images.xcassets */; };
Expand All @@ -35,7 +34,6 @@
4049CD781BC2D43F00F1E353 /* JMCMarchingAnts.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JMCMarchingAnts.app; sourceTree = BUILT_PRODUCTS_DIR; };
4049CD7C1BC2D43F00F1E353 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4049CD7D1BC2D43F00F1E353 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
4049CD801BC2D43F00F1E353 /* JMCMarchingAnts.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = JMCMarchingAnts.xcdatamodel; sourceTree = "<group>"; };
4049CD821BC2D43F00F1E353 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
4049CD851BC2D43F00F1E353 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
4049CD871BC2D43F00F1E353 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -91,7 +89,6 @@
4049CD841BC2D43F00F1E353 /* Main.storyboard */,
4049CD871BC2D43F00F1E353 /* Images.xcassets */,
4049CD891BC2D43F00F1E353 /* LaunchScreen.xib */,
4049CD7F1BC2D43F00F1E353 /* JMCMarchingAnts.xcdatamodeld */,
4026614B1BE7F52400BF39D6 /* 038420-glossy-black-icon-transport-travel-transportation-car9-sc44.png */,
4049CD7B1BC2D43F00F1E353 /* Supporting Files */,
);
Expand Down Expand Up @@ -167,8 +164,9 @@
4049CD701BC2D43F00F1E353 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftMigration = 0710;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0640;
LastUpgradeCheck = 0710;
ORGANIZATIONNAME = "Janusz Chudzynski";
TargetAttributes = {
4049CD771BC2D43F00F1E353 = {
Expand Down Expand Up @@ -229,7 +227,6 @@
4049CD831BC2D43F00F1E353 /* ViewController.swift in Sources */,
4049CDA41BC2D54B00F1E353 /* JMCMarchingAnts.swift in Sources */,
4049CD7E1BC2D43F00F1E353 /* AppDelegate.swift in Sources */,
4049CD811BC2D43F00F1E353 /* JMCMarchingAnts.xcdatamodeld in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -293,6 +290,7 @@
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -360,6 +358,7 @@
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = JMCMarchingAnts/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.jmc.quiz.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -373,6 +372,7 @@
CLANG_ENABLE_MODULES = YES;
INFOPLIST_FILE = JMCMarchingAnts/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.jmc.quiz.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
};
Expand All @@ -393,6 +393,7 @@
);
INFOPLIST_FILE = JMCMarchingAntsTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.jmc.quiz.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -411,6 +412,7 @@
);
INFOPLIST_FILE = JMCMarchingAntsTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.jmc.quiz.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JMCMarchingAnts.app/JMCMarchingAnts";
Expand Down Expand Up @@ -448,19 +450,6 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCVersionGroup section */
4049CD7F1BC2D43F00F1E353 /* JMCMarchingAnts.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
4049CD801BC2D43F00F1E353 /* JMCMarchingAnts.xcdatamodel */,
);
currentVersion = 4049CD801BC2D43F00F1E353 /* JMCMarchingAnts.xcdatamodel */;
path = JMCMarchingAnts.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
};
/* End XCVersionGroup section */
};
rootObject = 4049CD701BC2D43F00F1E353 /* Project object */;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0640"
LastUpgradeVersion = "0710"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -37,10 +37,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -62,15 +62,18 @@
ReferencedContainer = "container:JMCMarchingAnts.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand All @@ -86,10 +89,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down
65 changes: 2 additions & 63 deletions JMCMarchingAnts/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,71 +41,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
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: - 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 "com.jmc.quiz.JMCMarchingAnts" 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("JMCMarchingAnts", 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("JMCMarchingAnts.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()
}
}
}


}

5 changes: 3 additions & 2 deletions JMCMarchingAnts/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14F1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="14F1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand Down
2 changes: 1 addition & 1 deletion JMCMarchingAnts/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.jmc.quiz.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
Loading

0 comments on commit 44ae1f0

Please sign in to comment.