Skip to content

Commit dbae2b3

Browse files
committed
Finished updating example codes in chapter-addressBook to Swift 2.0 (Xcode 7)
1 parent e018c3e commit dbae2b3

File tree

17 files changed

+28
-24
lines changed

17 files changed

+28
-24
lines changed

chapter-addressBook/Adding Persons to Groups/Adding Persons to Groups.xcodeproj/project.pbxproj

+6-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
isa = PBXProject;
155155
attributes = {
156156
LastSwiftUpdateCheck = 0700;
157-
LastUpgradeCheck = 0600;
157+
LastUpgradeCheck = 0700;
158158
ORGANIZATIONNAME = "Pixolity Ltd.";
159159
TargetAttributes = {
160160
9D15831D198508E6008E2AC0 = {
@@ -264,6 +264,7 @@
264264
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
265265
COPY_PHASE_STRIP = NO;
266266
ENABLE_STRICT_OBJC_MSGSEND = YES;
267+
ENABLE_TESTABILITY = YES;
267268
GCC_C_LANGUAGE_STANDARD = gnu99;
268269
GCC_DYNAMIC_NO_PIC = NO;
269270
GCC_OPTIMIZATION_LEVEL = 0;
@@ -330,6 +331,7 @@
330331
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
331332
INFOPLIST_FILE = "Adding Persons to Groups/Info.plist";
332333
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
334+
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
333335
PRODUCT_NAME = "$(TARGET_NAME)";
334336
};
335337
name = Debug;
@@ -341,6 +343,7 @@
341343
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
342344
INFOPLIST_FILE = "Adding Persons to Groups/Info.plist";
343345
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
346+
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
344347
PRODUCT_NAME = "$(TARGET_NAME)";
345348
};
346349
name = Release;
@@ -359,6 +362,7 @@
359362
);
360363
INFOPLIST_FILE = "Adding Persons to GroupsTests/Info.plist";
361364
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
365+
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
362366
PRODUCT_NAME = "$(TARGET_NAME)";
363367
TEST_HOST = "$(BUNDLE_LOADER)";
364368
};
@@ -374,6 +378,7 @@
374378
);
375379
INFOPLIST_FILE = "Adding Persons to GroupsTests/Info.plist";
376380
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
381+
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
377382
PRODUCT_NAME = "$(TARGET_NAME)";
378383
TEST_HOST = "$(BUNDLE_LOADER)";
379384
};

chapter-addressBook/Adding Persons to Groups/Adding Persons to Groups.xcodeproj/xcuserdata/vandadnp.xcuserdatad/xcschemes/Adding Persons to Groups.xcscheme

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0600"
3+
LastUpgradeVersion = "0700"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -48,6 +48,8 @@
4848
ReferencedContainer = "container:Adding Persons to Groups.xcodeproj">
4949
</BuildableReference>
5050
</MacroExpansion>
51+
<AdditionalOptions>
52+
</AdditionalOptions>
5153
</TestAction>
5254
<LaunchAction
5355
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
@@ -57,8 +59,10 @@
5759
buildConfiguration = "Debug"
5860
ignoresPersistentStateOnLaunch = "NO"
5961
debugDocumentVersioning = "YES"
62+
debugServiceExtension = "internal"
6063
allowLocationSimulation = "YES">
61-
<BuildableProductRunnable>
64+
<BuildableProductRunnable
65+
runnableDebuggingMode = "0">
6266
<BuildableReference
6367
BuildableIdentifier = "primary"
6468
BlueprintIdentifier = "9D15831D198508E6008E2AC0"
@@ -76,7 +80,8 @@
7680
useCustomWorkingDirectory = "NO"
7781
buildConfiguration = "Release"
7882
debugDocumentVersioning = "YES">
79-
<BuildableProductRunnable>
83+
<BuildableProductRunnable
84+
runnableDebuggingMode = "0">
8085
<BuildableReference
8186
BuildableIdentifier = "primary"
8287
BlueprintIdentifier = "9D15831D198508E6008E2AC0"

chapter-addressBook/Adding Persons to Groups/Adding Persons to Groups/AppDelegate.swift

-3
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
221221
})
222222
case .Restricted:
223223
print("Access is restricted")
224-
225-
default:
226-
print("Unhandled")
227224
}
228225

229226
return true

chapter-addressBook/Adding Persons to Groups/Adding Persons to Groups/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>${EXECUTABLE_NAME}</string>
99
<key>CFBundleIdentifier</key>
10-
<string>com.pixolity.ios.cookbook.app</string>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1111
<key>CFBundleInfoDictionaryVersion</key>
1212
<string>6.0</string>
1313
<key>CFBundleName</key>

chapter-addressBook/Adding Persons to Groups/Adding Persons to GroupsTests/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>${EXECUTABLE_NAME}</string>
99
<key>CFBundleIdentifier</key>
10-
<string>com.pixolity.ios.cookbook.app</string>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1111
<key>CFBundleInfoDictionaryVersion</key>
1212
<string>6.0</string>
1313
<key>CFBundleName</key>

chapter-addressBook/Inserting a Group Entry into the Address Book/Inserting a Group Entry into the Address Book/AppDelegate.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
108108

109109
case .NotDetermined:
110110
ABAddressBookRequestAccessWithCompletion(addressBook,
111-
{[weak self] (granted: Bool, error: CFError!) in
111+
{granted, error in
112112

113113
if granted{
114-
let strongSelf = self!
115114
print("Access is granted")
116-
strongSelf.createNewGroupInAddressBook(strongSelf.addressBook)
115+
self.createNewGroupInAddressBook(self.addressBook)
117116
} else {
118117
print("Access is not granted")
119118
}

chapter-addressBook/Inserting a Person Entry into the Address Book/Inserting a Person Entry into the Address Book/AppDelegate.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
110110

111111
case .NotDetermined:
112112
ABAddressBookRequestAccessWithCompletion(addressBook,
113-
{[weak self] (granted: Bool, error: CFError!) in
113+
{granted, error in
114114

115115
if granted{
116-
let strongSelf = self!
117116
print("Access is granted")
118-
strongSelf.createContact()
117+
self.createContact()
119118
} else {
120119
print("Access is not granted")
121120
}

chapter-addressBook/Requesting Access to the Address Book/Requesting Access to the Address Book/AppDelegate.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5151
/* Now you can use the address book */
5252
case .Denied:
5353
print("You are denied access to address book")
54-
5554
case .NotDetermined:
5655
createAddressBook()
5756
if let theBook: ABAddressBookRef = addressBook{
5857
ABAddressBookRequestAccessWithCompletion(theBook,
59-
{(granted: Bool, error: CFError!) in
58+
{granted, error in
6059

6160
if granted{
6261
print("Access is granted")

chapter-addressBook/Retrieving a Person Entity with System UI/Retrieving a Person Entity with System UI/ViewController.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// report them to O'Reilly at the following URL:
2222
// http://www.oreilly.com/catalog/errata.csp?isbn=0636920034254
2323

24-
/* 1 */
24+
///* 1 */
2525
//import UIKit
2626
//import AddressBookUI
2727
//
@@ -41,13 +41,13 @@
4141
// }
4242
//
4343
// func peoplePickerNavigationControllerDidCancel(
44-
// peoplePicker: ABPeoplePickerNavigationController!){
44+
// peoplePicker: ABPeoplePickerNavigationController){
4545
// /* Mandatory to implement */
4646
// }
4747
//
4848
// func peoplePickerNavigationController(
49-
// peoplePicker: ABPeoplePickerNavigationController!,
50-
// didSelectPerson person: ABRecordRef!) {
49+
// peoplePicker: ABPeoplePickerNavigationController,
50+
// didSelectPerson person: ABRecordRef) {
5151
//
5252
// /* Do we know which picker this is? */
5353
// if peoplePicker != personPicker{
@@ -65,15 +65,15 @@
6565
// let phone = ABMultiValueCopyValueAtIndex(phones,
6666
// index).takeRetainedValue() as! String
6767
//
68-
// println(phone)
68+
// print(phone)
6969
//
7070
// }
7171
//
7272
// }
7373
//
7474
//}
75-
76-
/* 2 */
75+
//
76+
///* 2 */
7777
import UIKit
7878
import AddressBookUI
7979

0 commit comments

Comments
 (0)