Skip to content

Commit 5039b5f

Browse files
committed
Updated all code in chapter-multimedia to Swift 2.0 (Xcode 7)
1 parent 205dfd4 commit 5039b5f

File tree

31 files changed

+243
-187
lines changed

31 files changed

+243
-187
lines changed

chapter-multimedia/Accessing the Music Library/Accessing the Music Library.xcodeproj/project.pbxproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@
153153
9D595E7B196EB44700E60B3A /* Project object */ = {
154154
isa = PBXProject;
155155
attributes = {
156-
LastUpgradeCheck = 0600;
156+
LastSwiftUpdateCheck = 0700;
157+
LastUpgradeCheck = 0700;
157158
ORGANIZATIONNAME = "Pixolity Ltd.";
158159
TargetAttributes = {
159160
9D595E82196EB44700E60B3A = {
@@ -263,6 +264,7 @@
263264
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
264265
COPY_PHASE_STRIP = NO;
265266
ENABLE_STRICT_OBJC_MSGSEND = YES;
267+
ENABLE_TESTABILITY = YES;
266268
GCC_C_LANGUAGE_STANDARD = gnu99;
267269
GCC_DYNAMIC_NO_PIC = NO;
268270
GCC_OPTIMIZATION_LEVEL = 0;
@@ -329,6 +331,7 @@
329331
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
330332
INFOPLIST_FILE = "Accessing the Music Library/Info.plist";
331333
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
334+
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
332335
PRODUCT_NAME = "$(TARGET_NAME)";
333336
};
334337
name = Debug;
@@ -340,6 +343,7 @@
340343
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
341344
INFOPLIST_FILE = "Accessing the Music Library/Info.plist";
342345
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
346+
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
343347
PRODUCT_NAME = "$(TARGET_NAME)";
344348
};
345349
name = Release;
@@ -358,6 +362,7 @@
358362
);
359363
INFOPLIST_FILE = "Accessing the Music LibraryTests/Info.plist";
360364
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
365+
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
361366
PRODUCT_NAME = "$(TARGET_NAME)";
362367
TEST_HOST = "$(BUNDLE_LOADER)";
363368
};
@@ -373,6 +378,7 @@
373378
);
374379
INFOPLIST_FILE = "Accessing the Music LibraryTests/Info.plist";
375380
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
381+
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
376382
PRODUCT_NAME = "$(TARGET_NAME)";
377383
TEST_HOST = "$(BUNDLE_LOADER)";
378384
};
@@ -397,6 +403,7 @@
397403
9D595EA1196EB44700E60B3A /* Release */,
398404
);
399405
defaultConfigurationIsVisible = 0;
406+
defaultConfigurationName = Release;
400407
};
401408
9D595EA2196EB44700E60B3A /* Build configuration list for PBXNativeTarget "Accessing the Music LibraryTests" */ = {
402409
isa = XCConfigurationList;
@@ -405,6 +412,7 @@
405412
9D595EA4196EB44700E60B3A /* Release */,
406413
);
407414
defaultConfigurationIsVisible = 0;
415+
defaultConfigurationName = Release;
408416
};
409417
/* End XCConfigurationList section */
410418
};

chapter-multimedia/Accessing the Music Library/Accessing the Music Library.xcodeproj/xcuserdata/vandadnp.xcuserdatad/xcschemes/Accessing the Music Library.xcscheme

Lines changed: 8 additions & 3 deletions
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:Accessing the Music Library.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 = "9D595E82196EB44700E60B3A"
@@ -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 = "9D595E82196EB44700E60B3A"

chapter-multimedia/Accessing the Music Library/Accessing the Music Library/Base.lproj/Main.storyboard

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6185.7" systemVersion="14A261i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="ajs-a5-e16">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8121.17" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="ajs-a5-e16">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6181.2"/>
4+
<deployment identifier="iOS"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8101.14"/>
56
</dependencies>
67
<scenes>
78
<!--View Controller-->
@@ -13,7 +14,7 @@
1314
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
1415
</layoutGuides>
1516
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
16-
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
17+
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
1718
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1819
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
1920
</view>

chapter-multimedia/Accessing the Music Library/Accessing the Music Library/Info.plist

Lines changed: 1 addition & 1 deletion
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-multimedia/Accessing the Music Library/Accessing the Music Library/ViewController.swift

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
//
3030
// var mediaPicker: MPMediaPickerController?
3131
//
32-
// func mediaPicker(mediaPicker: MPMediaPickerController!,
33-
// didPickMediaItems mediaItemCollection: MPMediaItemCollection!){
32+
// func mediaPicker(mediaPicker: MPMediaPickerController,
33+
// didPickMediaItems mediaItemCollection: MPMediaItemCollection){
3434
//
3535
// for thisItem in mediaItemCollection.items as [MPMediaItem]{
3636
//
@@ -51,19 +51,19 @@
5151
//
5252
//
5353
// if let url = itemUrl{
54-
// println("Item URL = \(url)")
54+
// print("Item URL = \(url)")
5555
// }
5656
//
5757
// if let title = itemTitle{
58-
// println("Item Title = \(title)")
58+
// print("Item Title = \(title)")
5959
// }
6060
//
6161
// if let artist = itemArtist{
62-
// println("Item Artist = \(artist)")
62+
// print("Item Artist = \(artist)")
6363
// }
6464
//
6565
// if let artwork = itemArtwork{
66-
// println("Item Artwork = \(artwork)")
66+
// print("Item Artwork = \(artwork)")
6767
// }
6868
//
6969
// }
@@ -72,9 +72,9 @@
7272
//
7373
// }
7474
//
75-
// func mediaPickerDidCancel(mediaPicker: MPMediaPickerController!) {
75+
// func mediaPickerDidCancel(mediaPicker: MPMediaPickerController) {
7676
// /* The media picker was cancelled */
77-
// println("Media Picker was cancelled")
77+
// print("Media Picker was cancelled")
7878
// mediaPicker.dismissViewControllerAnimated(true, completion: nil)
7979
// }
8080
//
@@ -84,14 +84,14 @@
8484
//
8585
// if let picker = mediaPicker{
8686
//
87-
// println("Successfully instantiated a media picker")
87+
// print("Successfully instantiated a media picker")
8888
// picker.delegate = self
8989
// picker.allowsPickingMultipleItems = false
9090
//
9191
// presentViewController(picker, animated: true, completion: nil)
9292
//
9393
// } else {
94-
// println("Could not instantiate a media picker")
94+
// print("Could not instantiate a media picker")
9595
// }
9696
//
9797
// }
@@ -102,8 +102,8 @@
102102
// }
103103
//
104104
//}
105-
106-
/* 2 */
105+
//
106+
///* 2 */
107107
import UIKit
108108
import MediaPlayer
109109
import AVFoundation
@@ -118,7 +118,7 @@ MPMediaPickerControllerDelegate, AVAudioPlayerDelegate {
118118

119119
func musicPlayerStateChanged(notification: NSNotification){
120120

121-
println("Player State Changed")
121+
print("Player State Changed")
122122

123123
/* Let's get the state of the player */
124124
let stateAsObject =
@@ -131,34 +131,34 @@ MPMediaPickerControllerDelegate, AVAudioPlayerDelegate {
131131
switch MPMusicPlaybackState(rawValue: state.integerValue)!{
132132
case .Stopped:
133133
/* Here the media player has stopped playing the queue. */
134-
println("Stopped")
134+
print("Stopped")
135135
case .Playing:
136136
/* The media player is playing the queue. Perhaps you
137137
can reduce some processing that your application
138138
that is using to give more processing power
139139
to the media player */
140-
println("Paused")
140+
print("Paused")
141141
case .Paused:
142142
/* The media playback is paused here. You might want
143143
to indicate by showing graphics to the user */
144-
println("Paused")
144+
print("Paused")
145145
case .Interrupted:
146146
/* An interruption stopped the playback of the media queue */
147-
println("Interrupted")
147+
print("Interrupted")
148148
case .SeekingForward:
149149
/* The user is seeking forward in the queue */
150-
println("Seeking Forward")
150+
print("Seeking Forward")
151151
case .SeekingBackward:
152152
/* The user is seeking backward in the queue */
153-
println("Seeking Backward")
153+
print("Seeking Backward")
154154
}
155155

156156
}
157157
}
158158

159159
func nowPlayingItemIsChanged(notification: NSNotification){
160160

161-
println("Playing Item Is Changed")
161+
print("Playing Item Is Changed")
162162

163163
let key = "MPMusicPlayerControllerNowPlayingItemPersistentIDKey"
164164

@@ -167,20 +167,20 @@ MPMediaPickerControllerDelegate, AVAudioPlayerDelegate {
167167

168168
if let id = persistentID{
169169
/* Do something with Persistent ID */
170-
println("Persistent ID = \(id)")
170+
print("Persistent ID = \(id)")
171171
}
172172

173173
}
174174

175175
func volumeIsChanged(notification: NSNotification){
176-
println("Volume Is Changed")
176+
print("Volume Is Changed")
177177
/* The userInfo dictionary of this notification is normally empty */
178178
}
179179

180-
func mediaPicker(mediaPicker: MPMediaPickerController!,
181-
didPickMediaItems mediaItemCollection: MPMediaItemCollection!){
180+
func mediaPicker(mediaPicker: MPMediaPickerController,
181+
didPickMediaItems mediaItemCollection: MPMediaItemCollection){
182182

183-
println("Media Picker returned")
183+
print("Media Picker returned")
184184

185185
/* Instantiate the music player */
186186

@@ -221,9 +221,9 @@ MPMediaPickerControllerDelegate, AVAudioPlayerDelegate {
221221

222222
}
223223

224-
func mediaPickerDidCancel(mediaPicker: MPMediaPickerController!) {
224+
func mediaPickerDidCancel(mediaPicker: MPMediaPickerController) {
225225
/* The media picker was cancelled */
226-
println("Media Picker was cancelled")
226+
print("Media Picker was cancelled")
227227
mediaPicker.dismissViewControllerAnimated(true, completion: nil)
228228
}
229229

@@ -244,7 +244,7 @@ MPMediaPickerControllerDelegate, AVAudioPlayerDelegate {
244244
if let picker = mediaPicker{
245245

246246

247-
println("Successfully instantiated a media picker")
247+
print("Successfully instantiated a media picker")
248248
picker.delegate = self
249249
picker.allowsPickingMultipleItems = true
250250
picker.showsCloudItems = true
@@ -254,7 +254,7 @@ MPMediaPickerControllerDelegate, AVAudioPlayerDelegate {
254254
presentViewController(picker, animated: true, completion: nil)
255255

256256
} else {
257-
println("Could not instantiate a media picker")
257+
print("Could not instantiate a media picker")
258258
}
259259

260260
}
@@ -264,7 +264,7 @@ MPMediaPickerControllerDelegate, AVAudioPlayerDelegate {
264264

265265
title = "Media picker..."
266266

267-
buttonPickAndPlay = UIButton.buttonWithType(.System) as? UIButton
267+
buttonPickAndPlay = UIButton(type: .System)
268268

269269
if let pickAndPlay = buttonPickAndPlay{
270270
pickAndPlay.frame = CGRect(x: 0, y: 0, width: 200, height: 37)
@@ -276,7 +276,7 @@ MPMediaPickerControllerDelegate, AVAudioPlayerDelegate {
276276
view.addSubview(pickAndPlay)
277277
}
278278

279-
buttonStopPlaying = UIButton.buttonWithType(.System) as? UIButton
279+
buttonStopPlaying = UIButton(type: .System)
280280

281281
if let stopPlaying = buttonStopPlaying{
282282
stopPlaying.frame = CGRect(x: 0, y: 0, width: 200, height: 37)
@@ -291,4 +291,4 @@ MPMediaPickerControllerDelegate, AVAudioPlayerDelegate {
291291
}
292292

293293

294-
}
294+
}

chapter-multimedia/Accessing the Music Library/Accessing the Music LibraryTests/Info.plist

Lines changed: 1 addition & 1 deletion
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>

0 commit comments

Comments
 (0)