Skip to content

Commit caab3e2

Browse files
committed
Updated all example codes for Xcode Version 6.3 (6D532l) - Beta 2
1 parent 90caf53 commit caab3e2

File tree

10 files changed

+22
-22
lines changed

10 files changed

+22
-22
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
iOS 8 Swift Programming Cookbook (by: Vandad Nahavandipoor)
22
===============================
33

4-
__Updated for__: Xcode 6.3 Beta 1 6D520o
4+
__Updated for__: Xcode 6.3 Beta 2 6D532l
55

66
These example codes are written for O'Reilly's iOS 8 Swift Programming Cookbook
77
If you use these solutions in your apps, you can give attribution to

chapter-addressBook/Retrieving and Setting a Person's Address Book Image/Retrieving and Setting a Person's Address Book Image/AppDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3737

3838
func imageForPerson(person: ABRecordRef) -> UIImage?{
3939

40-
let data = ABPersonCopyImageData(person).takeRetainedValue() as! NSData
40+
let data = ABPersonCopyImageData(person).takeRetainedValue() as NSData
4141

4242
let image = UIImage(data: data)
4343
return image

chapter-basics/Presenting Temporary Information on the Screen with Popovers/Presenting Temporary Information on the Screen with Popovers/PopoverTableViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class PopoverTableViewController: UITableViewController {
5353
}()
5454

5555
var cancelBarButtonItem: UIBarButtonItem!
56-
var selectionHandler: ((selectedItem: String) -> Void!)?
56+
var selectionHandler: ((selectedItem: String) -> Void)?
5757

5858
override func viewDidLoad() {
5959
super.viewDidLoad()

chapter-camera/Detecting and Probing the Camera/Detecting and Probing the Camera/ViewController.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@
7171
// }
7272
//
7373
// func doesCameraSupportShootingVideos() -> Bool{
74-
// return cameraSupportsMedia(kUTTypeMovie as NSString, sourceType: .Camera)
74+
// return cameraSupportsMedia(kUTTypeMovie as! String, sourceType: .Camera)
7575
// }
7676
//
7777
// func doesCameraSupportTakingPhotos() -> Bool{
78-
// return cameraSupportsMedia(kUTTypeImage as NSString, sourceType: .Camera)
78+
// return cameraSupportsMedia(kUTTypeImage as! String, sourceType: .Camera)
7979
// }
8080
//
8181
// override func viewDidLoad() {
@@ -122,11 +122,11 @@ class ViewController: UIViewController {
122122
}
123123

124124
func doesCameraSupportShootingVideos() -> Bool{
125-
return cameraSupportsMedia(kUTTypeMovie as NSString as! String, sourceType: .Camera)
125+
return cameraSupportsMedia(kUTTypeMovie as! String, sourceType: .Camera)
126126
}
127127

128128
func doesCameraSupportTakingPhotos() -> Bool{
129-
return cameraSupportsMedia(kUTTypeImage as NSString as! String, sourceType: .Camera)
129+
return cameraSupportsMedia(kUTTypeImage as! String, sourceType: .Camera)
130130
}
131131

132132
func isFrontCameraAvailable() -> Bool{

chapter-camera/Storing Photos in the Photo Library/Storing Photos in the Photo Library/ViewController.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ UIImagePickerControllerDelegate, UINavigationControllerDelegate {
5656
if type is String{
5757
let stringType = type as! String
5858

59-
if stringType == kUTTypeImage as NSString{
59+
if stringType == kUTTypeImage as! String{
6060

6161
var theImage: UIImage!
6262

@@ -115,7 +115,7 @@ UIImagePickerControllerDelegate, UINavigationControllerDelegate {
115115
}
116116

117117
func doesCameraSupportTakingPhotos() -> Bool{
118-
return cameraSupportsMedia(kUTTypeImage as NSString as! String, sourceType: .Camera)
118+
return cameraSupportsMedia(kUTTypeImage as! String, sourceType: .Camera)
119119
}
120120

121121
override func viewDidAppear(animated: Bool) {
@@ -136,7 +136,7 @@ UIImagePickerControllerDelegate, UINavigationControllerDelegate {
136136
if let theController = controller{
137137
theController.sourceType = .Camera
138138

139-
theController.mediaTypes = [kUTTypeImage as NSString]
139+
theController.mediaTypes = [kUTTypeImage as! String]
140140

141141
theController.allowsEditing = true
142142
theController.delegate = self

chapter-camera/Taking Photos with the Camera/Taking Photos with the Camera/ViewController.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ UINavigationControllerDelegate, UIImagePickerControllerDelegate {
4545
if type is String{
4646
let stringType = type as! String
4747

48-
if stringType == kUTTypeMovie as NSString{
48+
if stringType == kUTTypeMovie as! String{
4949
let urlOfVideo = info[UIImagePickerControllerMediaURL] as? NSURL
5050
if let url = urlOfVideo{
5151
println("Video URL = \(url)")
5252
}
5353
}
5454

55-
else if stringType == kUTTypeImage as NSString as NSString{
55+
else if stringType == kUTTypeImage as! String{
5656
/* Let's get the metadata. This is only for images. Not videos */
5757
let metadata = info[UIImagePickerControllerMediaMetadata]
5858
as? NSDictionary
@@ -100,7 +100,7 @@ UINavigationControllerDelegate, UIImagePickerControllerDelegate {
100100
}
101101

102102
func doesCameraSupportTakingPhotos() -> Bool{
103-
return cameraSupportsMedia(kUTTypeImage as NSString as! String, sourceType: .Camera)
103+
return cameraSupportsMedia(kUTTypeImage as! String, sourceType: .Camera)
104104
}
105105

106106
override func viewDidAppear(animated: Bool) {
@@ -121,7 +121,7 @@ UINavigationControllerDelegate, UIImagePickerControllerDelegate {
121121
if let theController = controller{
122122
theController.sourceType = .Camera
123123

124-
theController.mediaTypes = [kUTTypeImage as NSString]
124+
theController.mediaTypes = [kUTTypeImage as! String]
125125

126126
theController.allowsEditing = true
127127
theController.delegate = self

chapter-camera/Taking Videos with the Camera/Taking Videos with the Camera/ViewController.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ UINavigationControllerDelegate, UIImagePickerControllerDelegate {
4343
if let type:AnyObject = mediaType{
4444

4545
if type is String{
46-
let stringType = type as String
46+
let stringType = type as! String
4747

48-
if stringType == kUTTypeMovie as NSString{
48+
if stringType == kUTTypeMovie as! String{
4949
let urlOfVideo = info[UIImagePickerControllerMediaURL] as? NSURL
5050
if let url = urlOfVideo{
5151

@@ -89,7 +89,7 @@ UINavigationControllerDelegate, UIImagePickerControllerDelegate {
8989
sourceType: UIImagePickerControllerSourceType) -> Bool{
9090

9191
let availableMediaTypes =
92-
UIImagePickerController.availableMediaTypesForSourceType(sourceType) as
92+
UIImagePickerController.availableMediaTypesForSourceType(sourceType) as!
9393
[String]?
9494

9595
if let types = availableMediaTypes{
@@ -104,7 +104,7 @@ UINavigationControllerDelegate, UIImagePickerControllerDelegate {
104104
}
105105

106106
func doesCameraSupportShootingVideos() -> Bool{
107-
return cameraSupportsMedia(kUTTypeMovie as NSString, sourceType: .Camera)
107+
return cameraSupportsMedia(kUTTypeMovie as! String, sourceType: .Camera)
108108
}
109109

110110
/* 1 */
@@ -126,7 +126,7 @@ UINavigationControllerDelegate, UIImagePickerControllerDelegate {
126126
// if let theController = controller{
127127
// theController.sourceType = .Camera
128128
//
129-
// theController.mediaTypes = [kUTTypeMovie as NSString]
129+
// theController.mediaTypes = [kUTTypeMovie as! String]
130130
//
131131
// theController.allowsEditing = true
132132
// theController.delegate = self
@@ -158,7 +158,7 @@ UINavigationControllerDelegate, UIImagePickerControllerDelegate {
158158
if let theController = controller{
159159
theController.sourceType = .Camera
160160

161-
theController.mediaTypes = [kUTTypeMovie as NSString]
161+
theController.mediaTypes = [kUTTypeMovie as! String]
162162

163163
theController.allowsEditing = true
164164
theController.delegate = self

chapter-extensions/Providing a Custom Sharing Extension to iOS/ShareExtension/ShareViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ AudienceSelectionViewControllerDelegate, NSURLSessionDelegate {
6161
placeholder = "Your comments"
6262

6363
let content = extensionContext!.inputItems[0] as! NSExtensionItem
64-
let contentType = kUTTypeImage as String
64+
let contentType = kUTTypeImage as! String
6565

6666
for attachment in content.attachments as! [NSItemProvider]{
6767
if attachment.hasItemConformingToTypeIdentifier(contentType){

chapter-fileManagement/Writing to and Reading from Files/Writing to and Reading from Files/AppDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
111111

112112
func example5(){
113113
let path = NSTemporaryDirectory() + "MyFile.txt"
114-
let chars = [CUnsignedChar("a"), CUnsignedChar("b")]
114+
let chars = [CUnsignedChar(ascii: "a"), CUnsignedChar(ascii: "b")]
115115
let data = NSData(bytes: chars, length: 2)
116116
if data.writeToFile(path, atomically: true){
117117
println("Wrote the data")

0 commit comments

Comments
 (0)