Skip to content

Commit dcc5034

Browse files
author
Steve Trease
committed
Updated to iOS 9 and Swift 2.0.
1 parent 07f866d commit dcc5034

File tree

11 files changed

+72
-67
lines changed

11 files changed

+72
-67
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Swift Push 3.xcodeproj/project.pbxproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@
166166
AAD81F4A19BB63E600B08E83 /* Project object */ = {
167167
isa = PBXProject;
168168
attributes = {
169-
LastUpgradeCheck = 0600;
169+
LastSwiftUpdateCheck = 0700;
170+
LastUpgradeCheck = 0700;
170171
ORGANIZATIONNAME = steve;
171172
TargetAttributes = {
172173
AAD81F5119BB63E600B08E83 = {
@@ -303,6 +304,7 @@
303304
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
304305
COPY_PHASE_STRIP = NO;
305306
ENABLE_STRICT_OBJC_MSGSEND = YES;
307+
ENABLE_TESTABILITY = YES;
306308
GCC_C_LANGUAGE_STANDARD = gnu99;
307309
GCC_DYNAMIC_NO_PIC = NO;
308310
GCC_OPTIMIZATION_LEVEL = 0;
@@ -372,6 +374,7 @@
372374
INFOPLIST_FILE = "Swift Push 3/Info.plist";
373375
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
374376
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
377+
PRODUCT_BUNDLE_IDENTIFIER = eu.trease.www.swift.push;
375378
PRODUCT_NAME = "$(TARGET_NAME)";
376379
PROVISIONING_PROFILE = "";
377380
};
@@ -386,6 +389,7 @@
386389
INFOPLIST_FILE = "Swift Push 3/Info.plist";
387390
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
388391
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
392+
PRODUCT_BUNDLE_IDENTIFIER = eu.trease.www.swift.push;
389393
PRODUCT_NAME = "$(TARGET_NAME)";
390394
PROVISIONING_PROFILE = "";
391395
};
@@ -405,6 +409,7 @@
405409
);
406410
INFOPLIST_FILE = "Swift Push 3Tests/Info.plist";
407411
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
412+
PRODUCT_BUNDLE_IDENTIFIER = "Trease.$(PRODUCT_NAME:rfc1034identifier)";
408413
PRODUCT_NAME = "$(TARGET_NAME)";
409414
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Swift Push 3.app/Swift Push 3";
410415
};
@@ -420,6 +425,7 @@
420425
);
421426
INFOPLIST_FILE = "Swift Push 3Tests/Info.plist";
422427
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
428+
PRODUCT_BUNDLE_IDENTIFIER = "Trease.$(PRODUCT_NAME:rfc1034identifier)";
423429
PRODUCT_NAME = "$(TARGET_NAME)";
424430
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Swift Push 3.app/Swift Push 3";
425431
};

Swift Push 3.xcodeproj/xcshareddata/xcschemes/Swift Push 3.xcscheme

Lines changed: 4 additions & 1 deletion
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"
@@ -62,6 +62,8 @@
6262
ReferencedContainer = "container:Swift Push 3.xcodeproj">
6363
</BuildableReference>
6464
</MacroExpansion>
65+
<AdditionalOptions>
66+
</AdditionalOptions>
6567
</TestAction>
6668
<LaunchAction
6769
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
@@ -71,6 +73,7 @@
7173
buildConfiguration = "Debug"
7274
ignoresPersistentStateOnLaunch = "NO"
7375
debugDocumentVersioning = "YES"
76+
debugServiceExtension = "internal"
7477
allowLocationSimulation = "YES">
7578
<BuildableProductRunnable
7679
runnableDebuggingMode = "0">

Swift Push 3/.DS_Store

0 Bytes
Binary file not shown.

Swift Push 3/AppDelegate.swift

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,42 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1919
// Override point for customization after application launch.
2020

2121
let versionNumber: AnyObject? = NSBundle.mainBundle().infoDictionary?["CFBundleVersion"]
22-
println ("version \(versionNumber!)")
22+
print ("version \(versionNumber!)")
2323

24-
var item = NotificationData()
24+
let item = NotificationData()
2525
item.alert = "Swift Push (\(versionNumber!)) starting on " + UIDevice.currentDevice().name
2626
notifications.insert(item, atIndex: 0)
2727

2828
switch (application.applicationState) {
2929
case UIApplicationState.Active:
30-
println ("didFinishLaunchingWithOptions - active")
30+
print ("didFinishLaunchingWithOptions - active")
3131
case UIApplicationState.Inactive:
32-
println ("didFinishLaunchingWithOptions - inactive")
32+
print ("didFinishLaunchingWithOptions - inactive")
3333
case UIApplicationState.Background:
34-
println ("didFinishLaunchingWithOptions - background")
35-
default:
36-
println ("didFinishLaunchingWithOptions - unknown application state")
34+
print ("didFinishLaunchingWithOptions - background")
3735
}
3836

39-
var types: UIUserNotificationType =
40-
UIUserNotificationType.Alert |
41-
UIUserNotificationType.Badge |
42-
UIUserNotificationType.Sound
37+
let types: UIUserNotificationType =
38+
[UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
4339

44-
var settings: UIUserNotificationSettings = UIUserNotificationSettings( forTypes: types, categories: nil )
40+
let settings: UIUserNotificationSettings = UIUserNotificationSettings( forTypes: types, categories: nil )
4541

4642
application.registerUserNotificationSettings( settings )
4743
application.registerForRemoteNotifications()
4844

4945
// screenshot notification
5046
let mainQueue = NSOperationQueue.mainQueue()
5147
NSNotificationCenter.defaultCenter().addObserverForName(UIApplicationUserDidTakeScreenshotNotification, object: nil, queue: mainQueue) { notification in
52-
println("screenshot taken")
48+
print("screenshot taken")
5349
}
5450
return true
5551
}
5652

5753

5854
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:NSData) {
59-
let existingToken: AnyObject? = NSUserDefaults.standardUserDefaults().objectForKey("deviceToken")
55+
// let existingToken: AnyObject? = NSUserDefaults.standardUserDefaults().objectForKey("deviceToken")
6056

61-
println("device token is " + deviceToken.description)
57+
print("device token is " + deviceToken.description)
6258
NSUserDefaults.standardUserDefaults().setObject(deviceToken.description as String, forKey:"deviceToken")
6359
NSUserDefaults.standardUserDefaults().synchronize()
6460

@@ -67,52 +63,52 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
6763
let versionNumber: AnyObject? = NSBundle.mainBundle().infoDictionary?["CFBundleVersion"]
6864

6965
// register device token with push service
70-
var request = NSMutableURLRequest(URL: NSURL(string: "http://www.trease.eu/ibeacon/swiftpush/")!)
71-
var session = NSURLSession.sharedSession()
66+
let request = NSMutableURLRequest(URL: NSURL(string: "http://www.trease.eu/ibeacon/swiftpush/")!)
67+
// var session = NSURLSession.sharedSession()
7268
request.HTTPMethod = "POST"
7369
var bodyData = "token=\(deviceToken.description)"
7470
bodyData += "&device=\(UIDevice.currentDevice().name)"
7571
bodyData += "&mode=\(mode!)"
7672
bodyData += "&version=\(versionNumber!)"
7773
request.HTTPBody = bodyData.dataUsingEncoding(NSUTF8StringEncoding)
78-
var connection = NSURLConnection(request: request, delegate: self, startImmediately: false)
74+
let connection = NSURLConnection(request: request, delegate: self, startImmediately: false)
7975
connection?.start()
8076
}
8177

8278

8379
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error:NSError) {
84-
println("Failed to register device token")
85-
println( error.localizedDescription )
80+
print("Failed to register device token")
81+
print( error.localizedDescription )
8682
}
8783

8884
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
8985
switch (application.applicationState) {
9086
case UIApplicationState.Active:
91-
println ("notification received by AppDeligate whilst active")
87+
print ("notification received by AppDeligate whilst active")
9288
case UIApplicationState.Inactive:
93-
println ("notification received by AppDeligate whilst inactive")
89+
print ("notification received by AppDeligate whilst inactive")
9490
case UIApplicationState.Background:
95-
println ("notification received by AppDeligate whilst in background")
91+
print ("notification received by AppDeligate whilst in background")
9692
default:
97-
println ("notification received by AppDeligate with unknown application state")
93+
print ("notification received by AppDeligate with unknown application state")
9894
}
99-
println (userInfo)
95+
print (userInfo)
10096

101-
var item = NotificationData()
97+
let item = NotificationData()
10298

10399
if let aps = userInfo["aps"] as? NSDictionary {
104100
if let alert = aps["alert"] as? String {
105101
item.alert = alert
106-
println ("alert: \(alert)")
102+
print ("alert: \(alert)")
107103
}
108104
}
109105
if let messageID = userInfo["messageID"] as? Int {
110106
item.messageID = messageID
111-
println ("messageID: \(messageID)")
107+
print ("messageID: \(messageID)")
112108
}
113109
if let timeStamp = userInfo["timestamp"] as? NSTimeInterval {
114110
item.timeStampSent = NSDate (timeIntervalSince1970: timeStamp)
115-
println ("timestamp: \(timeStamp)")
111+
print ("timestamp: \(timeStamp)")
116112
}
117113

118114
notifications.insert(item, atIndex: 0)
@@ -146,16 +142,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
146142

147143
func applicationWillTerminate(application: UIApplication) {
148144
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
149-
// Saves changes in the application's managed object context before the application terminates.
150-
self.saveContext()
151145
}
152146

153147
// MARK: - Core Data stack
154148

155149
lazy var applicationDocumentsDirectory: NSURL = {
156150
// The directory the application uses to store the Core Data store file. This code uses a directory named "Trease.Swift_Push_3" in the application's documents Application Support directory.
157151
let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
158-
return urls[urls.count-1] as! NSURL
152+
return urls[urls.count-1] as NSURL
159153
}()
160154

161155
lazy var managedObjectModel: NSManagedObjectModel = {
@@ -171,7 +165,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
171165
let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("Swift_Push_3.sqlite")
172166
var error: NSError? = nil
173167
var failureReason = "There was an error creating or loading the application's saved data."
174-
if coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil, error: &error) == nil {
168+
do {
169+
try coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil)
170+
} catch var error1 as NSError {
171+
error = error1
175172
coordinator = nil
176173
// Report any error we got.
177174
let dict = NSMutableDictionary()
@@ -183,6 +180,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
183180
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
184181
NSLog("Unresolved error \(error), \(error!.userInfo)")
185182
abort()
183+
} catch {
184+
fatalError()
186185
}
187186

188187
return coordinator
@@ -199,19 +198,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
199198
return managedObjectContext
200199
}()
201200

202-
// MARK: - Core Data Saving support
203-
204-
func saveContext () {
205-
if let moc = self.managedObjectContext {
206-
var error: NSError? = nil
207-
if moc.hasChanges && !moc.save(&error) {
208-
// Replace this implementation with code to handle the error appropriately.
209-
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
210-
NSLog("Unresolved error \(error), \(error!.userInfo)")
211-
abort()
212-
}
213-
}
214-
}
215201

216202
}
217203

Swift Push 3/Base.lproj/Main.storyboard

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +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="6751" systemVersion="14D127a" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="NEu-qu-DLA">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8121.17" systemVersion="15A178w" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="NEu-qu-DLA">
33
<dependencies>
44
<deployment version="2048" identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8101.14"/>
66
</dependencies>
77
<scenes>
88
<!--Swift Push-->
@@ -12,36 +12,45 @@
1212
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="bbB-Wg-KpG">
1313
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
1414
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
15+
<animations/>
1516
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
1617
<searchBar key="tableHeaderView" contentMode="scaleToFill" placeholder="Search" showsCancelButton="YES" id="eAE-ew-HFb">
1718
<rect key="frame" x="0.0" y="64" width="600" height="44"/>
1819
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
20+
<animations/>
1921
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no"/>
2022
<connections>
2123
<outlet property="delegate" destination="Ciy-dE-pCt" id="Kd5-bn-Rn3"/>
2224
</connections>
2325
</searchBar>
2426
<prototypes>
2527
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ReuseCell" textLabel="zI5-fr-ipi" detailTextLabel="3LV-oS-vV3" style="IBUITableViewCellStyleSubtitle" id="dCV-Qf-4PF">
26-
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
28+
<rect key="frame" x="0.0" y="130" width="600" height="44"/>
2729
<autoresizingMask key="autoresizingMask"/>
2830
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="dCV-Qf-4PF" id="nNg-o2-Q2w">
31+
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
2932
<autoresizingMask key="autoresizingMask"/>
3033
<subviews>
3134
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="zI5-fr-ipi">
35+
<rect key="frame" x="15" y="5" width="32" height="20"/>
3236
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
37+
<animations/>
3338
<fontDescription key="fontDescription" type="system" pointSize="16"/>
3439
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
3540
<nil key="highlightedColor"/>
3641
</label>
3742
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="3LV-oS-vV3">
43+
<rect key="frame" x="15" y="25" width="41" height="14"/>
3844
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
45+
<animations/>
3946
<fontDescription key="fontDescription" type="system" pointSize="11"/>
4047
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
4148
<nil key="highlightedColor"/>
4249
</label>
4350
</subviews>
51+
<animations/>
4452
</tableViewCellContentView>
53+
<animations/>
4554
</tableViewCell>
4655
</prototypes>
4756
<connections>
@@ -75,6 +84,7 @@
7584
<navigationBar key="navigationBar" contentMode="scaleToFill" id="tHv-9t-Jmk">
7685
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
7786
<autoresizingMask key="autoresizingMask"/>
87+
<animations/>
7888
</navigationBar>
7989
<nil name="viewControllers"/>
8090
<connections>

Swift Push 3/Info.plist

Lines changed: 2 additions & 2 deletions
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>eu.trease.www.swift.push</string>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1111
<key>CFBundleInfoDictionaryVersion</key>
1212
<string>6.0</string>
1313
<key>CFBundleName</key>
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>321</string>
22+
<string>325</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UIBackgroundModes</key>

0 commit comments

Comments
 (0)