Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swift3 conversion #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

swift3 conversion #11

wants to merge 1 commit into from

Conversation

rockrep
Copy link

@rockrep rockrep commented Dec 6, 2016

conversion to swift3

@rockrep rockrep mentioned this pull request Dec 21, 2016
@mdagostino
Copy link

thanksss!!!!!!!!!!

@Wei-Xia
Copy link

Wei-Xia commented Feb 17, 2017

Thanks! Bro

Copy link

@AdrianFerreyra AdrianFerreyra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now is a good time to handle optional unwrapping properly.

@@ -58,22 +55,22 @@ class GATracker {
#endif

self.tid = tid
self.appName = NSBundle.mainBundle().infoDictionary!["CFBundleName"] as! String
let nsObject: AnyObject? = NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"]
self.appName = Bundle.main.infoDictionary!["CFBundleName"] as! String

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should handle this conditional properly.

self.appName = NSBundle.mainBundle().infoDictionary!["CFBundleName"] as! String
let nsObject: AnyObject? = NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"]
self.appName = Bundle.main.infoDictionary!["CFBundleName"] as! String
let nsObject: AnyObject? = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as AnyObject?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here.
let nsObject: AnyObject? = Bundle.main.infoDictionary["CFBundleShorVersionString"] as? AnyObject should do the job.

let language = NSLocale.preferredLanguages().first
if language?.characters.count > 0 {
let language = NSLocale.preferredLanguages.first
if (language?.characters.count)! > 0 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe if (language?.characters.count ?? 0) > 0 ?

@@ -111,7 +108,7 @@ class GATracker {
else {
if (error != nil) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optionals should not be handled like this. Use if let error = error or some other optional binding mechanism.

@@ -111,7 +108,7 @@ class GATracker {
else {
if (error != nil) {
#if DEBUG
print(error!.description)
print(error!.localizedDescription)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proper handling will help you get rid of this forced-unwrapping usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants