Skip to content

Commit

Permalink
Update to new swift syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
yeahdongcn committed Mar 28, 2016
1 parent 426594e commit 4b942f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Source/RSCode128Generator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ public class RSCode128Generator: RSAbstractCodeGenerator, RSCheckDigitGenerator
var continousDigitsStartIndex:Int = NSNotFound
for i in 0..<contents.length() {
let character = contents[i]
var continousDigitsRange:Range<Int> = Range<Int>(start: 0, end: 0)
var continousDigitsRange:Range<Int> = Range<Int>(0..<0)
if DIGITS_STRING.location(character) == NSNotFound {
// Non digit found
if continousDigitsStartIndex != NSNotFound {
continousDigitsRange = Range<Int>(start: continousDigitsStartIndex, end: i)
continousDigitsRange = Range<Int>(continousDigitsStartIndex..<i)
} else {
let characterValue = CODE128_ALPHABET_STRING.location(character)
self.autoCodeTable.sequence.append(characterValue)
Expand All @@ -154,7 +154,7 @@ public class RSCode128Generator: RSAbstractCodeGenerator, RSCheckDigitGenerator
continousDigitsStartIndex = i
}
if continousDigitsStartIndex != NSNotFound && i == contents.length() - 1 {
continousDigitsRange = Range<Int>(start: continousDigitsStartIndex, end: i + 1)
continousDigitsRange = Range<Int>(continousDigitsStartIndex..<(i + 1))
}
}

Expand Down
8 changes: 4 additions & 4 deletions Source/RSCodeReaderViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public class RSCodeReaderViewController: UIViewController, AVCaptureMetadataOutp
self.output.metadataObjectTypes = self.output.availableMetadataObjectTypes
}

let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: "onTap:")
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(RSCodeReaderViewController.onTap(_:)))
self.view.addGestureRecognizer(tapGestureRecognizer)

self.focusMarkLayer.frame = self.view.bounds
Expand All @@ -263,8 +263,8 @@ public class RSCodeReaderViewController: UIViewController, AVCaptureMetadataOutp
override public func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)

NSNotificationCenter.defaultCenter().addObserver(self, selector: "onApplicationWillEnterForeground", name:UIApplicationWillEnterForegroundNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "onApplicationDidEnterBackground", name: UIApplicationDidEnterBackgroundNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(RSCodeReaderViewController.onApplicationWillEnterForeground), name:UIApplicationWillEnterForegroundNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(RSCodeReaderViewController.onApplicationDidEnterBackground), name: UIApplicationDidEnterBackgroundNotification, object: nil)

self.session.startRunning()
}
Expand Down Expand Up @@ -306,7 +306,7 @@ public class RSCodeReaderViewController: UIViewController, AVCaptureMetadataOutp
if let ticker = self.ticker {
ticker.invalidate()
}
self.ticker = NSTimer.scheduledTimerWithTimeInterval(0.4, target: self, selector: "onTick", userInfo: nil, repeats: true)
self.ticker = NSTimer.scheduledTimerWithTimeInterval(0.4, target: self, selector: #selector(RSCodeReaderViewController.onTick), userInfo: nil, repeats: true)
})
}
}

0 comments on commit 4b942f8

Please sign in to comment.