Skip to content

Commit

Permalink
Updated all example codes in chapter-maps to Swift 2.0 (Xcode 7)
Browse files Browse the repository at this point in the history
  • Loading branch information
vandadnp committed Jun 23, 2015
1 parent 2d4c1b5 commit 002a567
Show file tree
Hide file tree
Showing 106 changed files with 786 additions and 615 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
9D022AA01982643700AA8814 /* Adding_Rooms_to_the_User_s_HomeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D022A9F1982643700AA8814 /* Adding_Rooms_to_the_User_s_HomeTests.swift */; };
9D022AAB1982645200AA8814 /* ListHomesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D022AA91982645200AA8814 /* ListHomesViewController.swift */; };
9D022AAC1982645200AA8814 /* AddHomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D022AAA1982645200AA8814 /* AddHomeViewController.swift */; };
9D022AAF1982648E00AA8814 /* HomeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9D022AAE1982648E00AA8814 /* HomeKit.framework */; };
9D022AB11982654F00AA8814 /* ListRoomsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D022AB01982654F00AA8814 /* ListRoomsTableViewController.swift */; };
9D022AB31982685F00AA8814 /* AddRoomViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D022AB21982685F00AA8814 /* AddRoomViewController.swift */; };
/* End PBXBuildFile section */
Expand All @@ -40,7 +39,6 @@
9D022AA91982645200AA8814 /* ListHomesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListHomesViewController.swift; sourceTree = "<group>"; };
9D022AAA1982645200AA8814 /* AddHomeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddHomeViewController.swift; sourceTree = "<group>"; };
9D022AAD1982648E00AA8814 /* Adding Rooms to the User’s Home.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Adding Rooms to the User’s Home.entitlements"; sourceTree = "<group>"; };
9D022AAE1982648E00AA8814 /* HomeKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HomeKit.framework; path = System/Library/Frameworks/HomeKit.framework; sourceTree = SDKROOT; };
9D022AB01982654F00AA8814 /* ListRoomsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRoomsTableViewController.swift; sourceTree = "<group>"; };
9D022AB21982685F00AA8814 /* AddRoomViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddRoomViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand All @@ -50,7 +48,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9D022AAF1982648E00AA8814 /* HomeKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -67,7 +64,6 @@
9D022A7E1982643700AA8814 = {
isa = PBXGroup;
children = (
9D022AAE1982648E00AA8814 /* HomeKit.framework */,
9D022A891982643700AA8814 /* Adding Rooms to the User’s Home */,
9D022A9C1982643700AA8814 /* Adding Rooms to the User’s HomeTests */,
9D022A881982643700AA8814 /* Products */,
Expand Down Expand Up @@ -168,7 +164,8 @@
9D022A7F1982643700AA8814 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0600;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Pixolity Ltd.";
TargetAttributes = {
9D022A861982643700AA8814 = {
Expand Down Expand Up @@ -287,6 +284,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -356,6 +354,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
INFOPLIST_FILE = "Adding Rooms to the User’s Home/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
};
Expand All @@ -371,6 +370,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
INFOPLIST_FILE = "Adding Rooms to the User’s Home/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
};
Expand All @@ -390,6 +390,7 @@
);
INFOPLIST_FILE = "Adding Rooms to the User’s HomeTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
};
Expand All @@ -405,6 +406,7 @@
);
INFOPLIST_FILE = "Adding Rooms to the User’s HomeTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
};
Expand All @@ -429,6 +431,7 @@
9D022AA51982643700AA8814 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
9D022AA61982643700AA8814 /* Build configuration list for PBXNativeTarget "Adding Rooms to the User’s HomeTests" */ = {
isa = XCConfigurationList;
Expand All @@ -437,6 +440,7 @@
9D022AA81982643700AA8814 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0600"
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -48,6 +48,8 @@
ReferencedContainer = "container:Adding Rooms to the User&#x2019;s Home.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
Expand All @@ -57,8 +59,10 @@
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9D022A861982643700AA8814"
Expand All @@ -76,7 +80,8 @@
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9D022A861982643700AA8814"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,22 @@ class AddHomeViewController: UIViewController {

@IBAction func addHome(){

if count(textField.text) == 0{
guard let text = textField.text where text.characters.count > 0 else {
UIAlertController.showAlertControllerOnHostController(self,
title: "Home name", message: "Please enter the home name",
buttonTitle: "OK")
return
}

homeManager.addHomeWithName(textField.text,
completionHandler: {[weak self] (home: HMHome!, error: NSError!) in

let strongSelf = self!
homeManager.addHomeWithName(text,
completionHandler: {home, error in

if error != nil{
UIAlertController.showAlertControllerOnHostController(strongSelf,
UIAlertController.showAlertControllerOnHostController(self,
title: "Error happened", message: "\(error)",
buttonTitle: "OK")
} else {
strongSelf.navigationController!.popViewControllerAnimated(true)
self.navigationController!.popViewControllerAnimated(true)
}

})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,21 @@ class AddRoomViewController: UIViewController{

@IBAction func addRoom(){

if count(textField.text) == 0{
guard let text = textField.text where text.characters.count > 0 else {
UIAlertController.showAlertControllerOnHostController(self,
title: "Room name", message: "Please enter the room name",
buttonTitle: "OK")
return
}

home.addRoomWithName(textField.text, completionHandler: {[weak self]
(room: HMRoom!, error: NSError!) in

let strongSelf = self!
home.addRoomWithName(textField.text!, completionHandler: {room, error in

if error != nil{
UIAlertController.showAlertControllerOnHostController(strongSelf,
UIAlertController.showAlertControllerOnHostController(self,
title: "Error happened", message: "\(error)",
buttonTitle: "OK")
} else {
strongSelf.navigationController!.popViewControllerAnimated(true)
self.navigationController!.popViewControllerAnimated(true)
}

})
Expand Down
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.pixolity.ios.cookbook.app</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ class ListHomesViewController: UITableViewController, HMHomeManagerDelegate{

let cell = tableView.dequeueReusableCellWithIdentifier(
TableViewValues.identifier, forIndexPath: indexPath)
as! UITableViewCell
as UITableViewCell

let home = homeManager.homes[indexPath.row] as! HMHome
let home = homeManager.homes[indexPath.row] as HMHome

cell.textLabel!.text = home.name
cell.accessoryType = .DisclosureIndicator
Expand All @@ -90,8 +90,8 @@ class ListHomesViewController: UITableViewController, HMHomeManagerDelegate{

}

func homeManager(manager: HMHomeManager, didRemoveHome home: HMHome!) {
println("A home has been deleted")
func homeManager(manager: HMHomeManager, didRemoveHome home: HMHome) {
print("A home has been deleted")
}

func homeManagerDidUpdateHomes(manager: HMHomeManager) {
Expand All @@ -114,8 +114,8 @@ class ListHomesViewController: UITableViewController, HMHomeManagerDelegate{
as! ListRoomsTableViewController
controller.homeManager = homeManager

let home = homeManager.homes[tableView.indexPathForSelectedRow()!.row]
as! HMHome
let home = homeManager.homes[tableView.indexPathForSelectedRow!.row]
as HMHome

controller.home = home
}
Expand All @@ -130,14 +130,11 @@ class ListHomesViewController: UITableViewController, HMHomeManagerDelegate{

if editingStyle == .Delete{

let home = homeManager.homes[indexPath.row] as! HMHome
homeManager.removeHome(home, completionHandler: {[weak self]
(error: NSError!) in

let strongSelf = self!
let home = homeManager.homes[indexPath.row] as HMHome
homeManager.removeHome(home, completionHandler: {error in

if error != nil{
UIAlertController.showAlertControllerOnHostController(strongSelf,
UIAlertController.showAlertControllerOnHostController(self,
title: "Error",
message: "An error occurred = \(error)",
buttonTitle: "OK")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class ListRoomsTableViewController: UITableViewController, HMHomeDelegate {

let addRoomSegueIdentifier = "addRoom"

func home(home: HMHome, didAddRoom room: HMRoom!) {
println("Added a new room to the home")
func home(home: HMHome, didAddRoom room: HMRoom) {
print("Added a new room to the home")
}

func home(home: HMHome, didRemoveRoom room: HMRoom!) {
println("A room has been removed from the home")
func home(home: HMHome, didRemoveRoom room: HMRoom) {
print("A room has been removed from the home")
}

override func tableView(tableView: UITableView,
Expand All @@ -58,9 +58,9 @@ class ListRoomsTableViewController: UITableViewController, HMHomeDelegate {

let cell = tableView.dequeueReusableCellWithIdentifier(
TableViewValues.identifier, forIndexPath: indexPath)
as! UITableViewCell
as UITableViewCell

let room = home.rooms[indexPath.row] as! HMRoom
let room = home.rooms[indexPath.row] as HMRoom

cell.textLabel!.text = room.name

Expand All @@ -74,14 +74,11 @@ class ListRoomsTableViewController: UITableViewController, HMHomeDelegate {

if editingStyle == .Delete{

let room = home.rooms[indexPath.row] as! HMRoom
home.removeRoom(room, completionHandler: {[weak self]
(error: NSError!) in

let strongSelf = self!
let room = home.rooms[indexPath.row] as HMRoom
home.removeRoom(room, completionHandler: {error in

if error != nil{
UIAlertController.showAlertControllerOnHostController(strongSelf,
UIAlertController.showAlertControllerOnHostController(self,
title: "Error",
message: "An error occurred = \(error)",
buttonTitle: "OK")
Expand Down
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.pixolity.ios.cookbook.app</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
Loading

0 comments on commit 002a567

Please sign in to comment.