Skip to content

Commit

Permalink
Updated all example codes for Xcode Version 6.3 (6D532l) - Beta 2
Browse files Browse the repository at this point in the history
  • Loading branch information
vandadnp committed Feb 24, 2015
1 parent 90caf53 commit caab3e2
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
iOS 8 Swift Programming Cookbook (by: Vandad Nahavandipoor)
===============================

__Updated for__: Xcode 6.3 Beta 1 6D520o
__Updated for__: Xcode 6.3 Beta 2 6D532l

These example codes are written for O'Reilly's iOS 8 Swift Programming Cookbook
If you use these solutions in your apps, you can give attribution to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

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

let data = ABPersonCopyImageData(person).takeRetainedValue() as! NSData
let data = ABPersonCopyImageData(person).takeRetainedValue() as NSData

let image = UIImage(data: data)
return image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PopoverTableViewController: UITableViewController {
}()

var cancelBarButtonItem: UIBarButtonItem!
var selectionHandler: ((selectedItem: String) -> Void!)?
var selectionHandler: ((selectedItem: String) -> Void)?

override func viewDidLoad() {
super.viewDidLoad()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
// }
//
// func doesCameraSupportShootingVideos() -> Bool{
// return cameraSupportsMedia(kUTTypeMovie as NSString, sourceType: .Camera)
// return cameraSupportsMedia(kUTTypeMovie as! String, sourceType: .Camera)
// }
//
// func doesCameraSupportTakingPhotos() -> Bool{
// return cameraSupportsMedia(kUTTypeImage as NSString, sourceType: .Camera)
// return cameraSupportsMedia(kUTTypeImage as! String, sourceType: .Camera)
// }
//
// override func viewDidLoad() {
Expand Down Expand Up @@ -122,11 +122,11 @@ class ViewController: UIViewController {
}

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

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

func isFrontCameraAvailable() -> Bool{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ UIImagePickerControllerDelegate, UINavigationControllerDelegate {
if type is String{
let stringType = type as! String

if stringType == kUTTypeImage as NSString{
if stringType == kUTTypeImage as! String{

var theImage: UIImage!

Expand Down Expand Up @@ -115,7 +115,7 @@ UIImagePickerControllerDelegate, UINavigationControllerDelegate {
}

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

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

theController.mediaTypes = [kUTTypeImage as NSString]
theController.mediaTypes = [kUTTypeImage as! String]

theController.allowsEditing = true
theController.delegate = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ UINavigationControllerDelegate, UIImagePickerControllerDelegate {
if type is String{
let stringType = type as! String

if stringType == kUTTypeMovie as NSString{
if stringType == kUTTypeMovie as! String{
let urlOfVideo = info[UIImagePickerControllerMediaURL] as? NSURL
if let url = urlOfVideo{
println("Video URL = \(url)")
}
}

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

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

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

theController.mediaTypes = [kUTTypeImage as NSString]
theController.mediaTypes = [kUTTypeImage as! String]

theController.allowsEditing = true
theController.delegate = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ UINavigationControllerDelegate, UIImagePickerControllerDelegate {
if let type:AnyObject = mediaType{

if type is String{
let stringType = type as String
let stringType = type as! String

if stringType == kUTTypeMovie as NSString{
if stringType == kUTTypeMovie as! String{
let urlOfVideo = info[UIImagePickerControllerMediaURL] as? NSURL
if let url = urlOfVideo{

Expand Down Expand Up @@ -89,7 +89,7 @@ UINavigationControllerDelegate, UIImagePickerControllerDelegate {
sourceType: UIImagePickerControllerSourceType) -> Bool{

let availableMediaTypes =
UIImagePickerController.availableMediaTypesForSourceType(sourceType) as
UIImagePickerController.availableMediaTypesForSourceType(sourceType) as!
[String]?

if let types = availableMediaTypes{
Expand All @@ -104,7 +104,7 @@ UINavigationControllerDelegate, UIImagePickerControllerDelegate {
}

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

/* 1 */
Expand All @@ -126,7 +126,7 @@ UINavigationControllerDelegate, UIImagePickerControllerDelegate {
// if let theController = controller{
// theController.sourceType = .Camera
//
// theController.mediaTypes = [kUTTypeMovie as NSString]
// theController.mediaTypes = [kUTTypeMovie as! String]
//
// theController.allowsEditing = true
// theController.delegate = self
Expand Down Expand Up @@ -158,7 +158,7 @@ UINavigationControllerDelegate, UIImagePickerControllerDelegate {
if let theController = controller{
theController.sourceType = .Camera

theController.mediaTypes = [kUTTypeMovie as NSString]
theController.mediaTypes = [kUTTypeMovie as! String]

theController.allowsEditing = true
theController.delegate = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ AudienceSelectionViewControllerDelegate, NSURLSessionDelegate {
placeholder = "Your comments"

let content = extensionContext!.inputItems[0] as! NSExtensionItem
let contentType = kUTTypeImage as String
let contentType = kUTTypeImage as! String

for attachment in content.attachments as! [NSItemProvider]{
if attachment.hasItemConformingToTypeIdentifier(contentType){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func example5(){
let path = NSTemporaryDirectory() + "MyFile.txt"
let chars = [CUnsignedChar("a"), CUnsignedChar("b")]
let chars = [CUnsignedChar(ascii: "a"), CUnsignedChar(ascii: "b")]
let data = NSData(bytes: chars, length: 2)
if data.writeToFile(path, atomically: true){
println("Wrote the data")
Expand Down
Binary file not shown.

0 comments on commit caab3e2

Please sign in to comment.