Skip to content

Commit ebb6cc2

Browse files
author
Richard Piazza
committed
Addressed swift deprecations.
1 parent d75c7ce commit ebb6cc2

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

CodeQuickKit-Swift/NSBundle.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ public extension NSBundle {
150150
return moduleClass!
151151
}
152152

153-
let firstRange = Range(start: classNamed.startIndex, end: classNamed.startIndex.advancedBy(1))
154-
let endRange = Range(start: classNamed.endIndex.advancedBy(-1), end: classNamed.endIndex)
153+
let firstRange = classNamed.startIndex..<classNamed.startIndex.advancedBy(1)
154+
let endRange = classNamed.endIndex.advancedBy(-1)..<classNamed.endIndex
155155

156156
var singular = classNamed
157157
singular.replaceRange(firstRange, with: singular.substringWithRange(firstRange).uppercaseString)

CodeQuickKit-Swift/NSFileManager.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public extension NSFileManager {
131131
var documentQuery: NSMetadataQuery?
132132
var documentsCompletion: UbiquityDocumentsCompletion?
133133

134-
func nsMetadataQueryDidFinishGathering(notification: NSNotification) {
134+
@objc func nsMetadataQueryDidFinishGathering(notification: NSNotification) {
135135
guard let documentQuery = self.documentQuery else {
136136
return
137137
}
@@ -155,7 +155,7 @@ public extension NSFileManager {
155155
documentQuery.enableUpdates()
156156
}
157157

158-
func nsMetadataQueryDidUpdate(notification: NSNotification) {
158+
@objc func nsMetadataQueryDidUpdate(notification: NSNotification) {
159159
guard let documentQuery = self.documentQuery else {
160160
return
161161
}
@@ -290,8 +290,9 @@ public extension NSFileManager {
290290
documentQuery.predicate = NSPredicate(format: "%K == *", argumentArray: [NSMetadataItemFSNameKey])
291291
}
292292

293-
NSNotificationCenter.defaultCenter().addObserver(NSFileManager.ubiquityContainer, selector: Selector("nsMetadataQueryDidFinishGathering:"), name: NSMetadataQueryDidFinishGatheringNotification, object: nil)
294-
NSNotificationCenter.defaultCenter().addObserver(NSFileManager.ubiquityContainer, selector: Selector("nsMetadataQueryDidUpdate:"), name: NSMetadataQueryDidUpdateNotification, object: nil)
293+
294+
NSNotificationCenter.defaultCenter().addObserver(NSFileManager.ubiquityContainer, selector: #selector(UbiquityContainer.nsMetadataQueryDidFinishGathering(_:)), name: NSMetadataQueryDidFinishGatheringNotification, object: nil)
295+
NSNotificationCenter.defaultCenter().addObserver(NSFileManager.ubiquityContainer, selector: #selector(UbiquityContainer.nsMetadataQueryDidUpdate(_:)), name: NSMetadataQueryDidUpdateNotification, object: nil)
295296

296297
documentQuery.startQuery()
297298
}

CodeQuickKit-Swift/NSObject.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public extension NSObject {
3434
return nil
3535
}
3636

37-
let range = Range<String.Index>(start: propertyName.startIndex, end: propertyName.startIndex.advancedBy(1))
37+
let range = propertyName.startIndex..<propertyName.startIndex.advancedBy(1)
3838
let character = propertyName.substringWithRange(range).uppercaseString
3939
let setter = propertyName.stringByReplacingCharactersInRange(range, withString: character)
4040

CodeQuickKit-Swift/Serializer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ public class Serializer {
201201

202202
switch (keyStyle) {
203203
case .TitleCase:
204-
let range: Range = Range<String.Index>(start: string.startIndex, end: string.startIndex.advancedBy(1))
204+
let range: Range = string.startIndex..<string.startIndex.advancedBy(1)
205205
let sub = string.substringWithRange(range).uppercaseString
206206
return string.stringByReplacingCharactersInRange(range, withString: sub)
207207
case .CamelCase:
208-
let range: Range = Range<String.Index>(start: string.startIndex, end: string.startIndex.advancedBy(1))
208+
let range: Range = string.startIndex..<string.startIndex.advancedBy(1)
209209
let sub = string.substringWithRange(range).lowercaseString
210210
return string.stringByReplacingCharactersInRange(range, withString: sub)
211211
case .UpperCase: return string.uppercaseString

CodeQuickKit-Swift/UIAlertController.swift

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ public extension UIAlertController {
7575
}
7676

7777
/// A basic message and single button `.Default` alert
78-
public static func prompt(var presentedFrom vc: UIViewController?, withMessage message: String?, action: String = "OK") {
78+
public static func prompt(presentedFrom vc: UIViewController?, withMessage message: String?, action: String = "OK") {
7979
manager.dismiss()
80+
81+
var vc = vc
8082
if vc == nil {
8183
vc = UIApplication.sharedApplication().delegate?.window??.rootViewController
8284
}
@@ -100,8 +102,10 @@ public extension UIAlertController {
100102
}
101103

102104
/// A configurable `.Default` alert
103-
public static func alert(var presentedFrom vc: UIViewController?, withTitle title: String?, message: String?, cancelAction: String?, destructiveAction: String?, otherActions: [String]?, completion: DefaultAlertCompletion) {
105+
public static func alert(presentedFrom vc: UIViewController?, withTitle title: String?, message: String?, cancelAction: String?, destructiveAction: String?, otherActions: [String]?, completion: DefaultAlertCompletion) {
104106
manager.dismiss()
107+
108+
var vc = vc
105109
if vc == nil {
106110
vc = UIApplication.sharedApplication().delegate?.window??.rootViewController
107111
}
@@ -150,8 +154,10 @@ public extension UIAlertController {
150154
}
151155

152156
/// A configurable `.Default` style alert with a single `UITextField`
153-
public static func textAlert(var presentedFrom vc: UIViewController?, withTitle title: String?, message: String?, initialText: String?, cancelAction: String?, otherActions: [String]?, completion: TextAlertCompletion) {
157+
public static func textAlert(presentedFrom vc: UIViewController?, withTitle title: String?, message: String?, initialText: String?, cancelAction: String?, otherActions: [String]?, completion: TextAlertCompletion) {
154158
manager.dismiss()
159+
160+
var vc = vc
155161
if vc == nil {
156162
vc = UIApplication.sharedApplication().delegate?.window??.rootViewController
157163
}
@@ -196,8 +202,10 @@ public extension UIAlertController {
196202
}
197203

198204
/// A configurable `.Default` style alert with a single secure `UITextField`
199-
public static func secureAlert(var presentedFrom vc: UIViewController?, withTitle title: String?, message: String?, initialText: String?, cancelAction: String?, otherActions: [String]?, completion: TextAlertCompletion) {
205+
public static func secureAlert(presentedFrom vc: UIViewController?, withTitle title: String?, message: String?, initialText: String?, cancelAction: String?, otherActions: [String]?, completion: TextAlertCompletion) {
200206
manager.dismiss()
207+
208+
var vc = vc
201209
if vc == nil {
202210
vc = UIApplication.sharedApplication().delegate?.window??.rootViewController
203211
}
@@ -244,8 +252,10 @@ public extension UIAlertController {
244252

245253
/// A configurable `.Default` style alert with two `UITextField`s, the
246254
/// second of which is secure
247-
public static func credentialAlert(var presentedFrom vc: UIViewController?, withTitle title: String?, message: String?, initialCredentials: NSURLCredential?, cancelAction: String?, otherActions: [String]?, completion: CredentialAlertCompletion) {
255+
public static func credentialAlert(presentedFrom vc: UIViewController?, withTitle title: String?, message: String?, initialCredentials: NSURLCredential?, cancelAction: String?, otherActions: [String]?, completion: CredentialAlertCompletion) {
248256
manager.dismiss()
257+
258+
var vc = vc
249259
if vc == nil {
250260
vc = UIApplication.sharedApplication().delegate?.window??.rootViewController
251261
}
@@ -304,8 +314,10 @@ public extension UIAlertController {
304314

305315
/// A configurable `.ActionSheet` style alert presented from the
306316
/// `viewController` or `sourceView` on Regular horizontal size classes
307-
public static func sheet(var presentedFrom vc: UIViewController?, withBarButtonItem barButtonItem: UIBarButtonItem?, orSourceView sourceView: UIView?, title: String?, message: String?, cancelAction: String?, destructiveAction: String?, otherActions: [String]?, completion: DefaultAlertCompletion) {
317+
public static func sheet(presentedFrom vc: UIViewController?, withBarButtonItem barButtonItem: UIBarButtonItem?, orSourceView sourceView: UIView?, title: String?, message: String?, cancelAction: String?, destructiveAction: String?, otherActions: [String]?, completion: DefaultAlertCompletion) {
308318
manager.dismiss()
319+
320+
var vc = vc
309321
if vc == nil {
310322
vc = UIApplication.sharedApplication().delegate?.window??.rootViewController
311323
}

0 commit comments

Comments
 (0)