I don't know anything about mailcore2
, nor have you provided any Time Profiler information to help narrow down what takes so long to complete the action (is it just a slow network, or is it something in your code? Anyone's guess), so I can't really address the slowness issue. I also don't have a clue which methods are yours versus what you simply get from mailcore2
, but with that said...
NSLog()
statements should almost always be wrapped in #if DEBUG
and #endif
statements. NSLog()
statements should almost always be wrapped in #if DEBUG
and #endif
statements.
Moreover, regardless of whether or not the deletion is successfully, we need to let the user know one way or the other, and NSLog()
isn't going to cut it.
I'm not sure how the second code snippet ties to the first, but all of our methods could use better names.
deleteOnServer(indexSet:)
- delete what? on which server? What does index set represent?
createNewIMAPSessionWith
- the words New
and With
can both be removed from this method. Although, what would probably be best is simply creating a factory method:
extension MCOIMAPSession {
class func session(userName: String, hostname: String, oauth2Token: String) -> MCOIMAPSession {
// all the code you're already doing
}
}
And then we call it simply like this:
let imapSession = MCOIMAPSession.session(userName:"username", hostname:"hostname", oauth2Token:"token")
localCopyMessageOperation!.start
This is a pretty big no-no, in my opinion. If the method we're calling to get localCopyMessageOperation
returns an optional, then we should use real optional chaining, not forced unwrapping. It's as simple as changing the exclamation point to a question mark and it prevents an "found nil when unwrapping" (or whatever it's called) exception.
I don't know anything about mailcore2
, nor have you provided any Time Profiler information to help narrow down what takes so long to complete the action (is it just a slow network, or is it something in your code? Anyone's guess), so I can't really address the slowness issue. I also don't have a clue which methods are yours versus what you simply get from mailcore2
, but with that said...
NSLog()
statements should almost always be wrapped in #if DEBUG
and #endif
statements.
Moreover, regardless of whether or not the deletion is successfully, we need to let the user know one way or the other, and NSLog()
isn't going to cut it.
I'm not sure how the second code snippet ties to the first, but all of our methods could use better names.
deleteOnServer(indexSet:)
- delete what? on which server? What does index set represent?
createNewIMAPSessionWith
- the words New
and With
can both be removed from this method. Although, what would probably be best is simply creating a factory method:
extension MCOIMAPSession {
class func session(userName: String, hostname: String, oauth2Token: String) -> MCOIMAPSession {
// all the code you're already doing
}
}
And then we call it simply like this:
let imapSession = MCOIMAPSession.session(userName:"username", hostname:"hostname", oauth2Token:"token")
localCopyMessageOperation!.start
This is a pretty big no-no, in my opinion. If the method we're calling to get localCopyMessageOperation
returns an optional, then we should use real optional chaining, not forced unwrapping. It's as simple as changing the exclamation point to a question mark and it prevents an "found nil when unwrapping" (or whatever it's called) exception.
I don't know anything about mailcore2
, nor have you provided any Time Profiler information to help narrow down what takes so long to complete the action (is it just a slow network, or is it something in your code? Anyone's guess), so I can't really address the slowness issue. I also don't have a clue which methods are yours versus what you simply get from mailcore2
, but with that said...
NSLog()
statements should almost always be wrapped in #if DEBUG
and #endif
statements.
Moreover, regardless of whether or not the deletion is successfully, we need to let the user know one way or the other, and NSLog()
isn't going to cut it.
I'm not sure how the second code snippet ties to the first, but all of our methods could use better names.
deleteOnServer(indexSet:)
- delete what? on which server? What does index set represent?
createNewIMAPSessionWith
- the words New
and With
can both be removed from this method. Although, what would probably be best is simply creating a factory method:
extension MCOIMAPSession {
class func session(userName: String, hostname: String, oauth2Token: String) -> MCOIMAPSession {
// all the code you're already doing
}
}
And then we call it simply like this:
let imapSession = MCOIMAPSession.session(userName:"username", hostname:"hostname", oauth2Token:"token")
localCopyMessageOperation!.start
This is a pretty big no-no, in my opinion. If the method we're calling to get localCopyMessageOperation
returns an optional, then we should use real optional chaining, not forced unwrapping. It's as simple as changing the exclamation point to a question mark and it prevents an "found nil when unwrapping" (or whatever it's called) exception.
I don't know anything about mailcore2
, nor have you provided any Time Profiler information to help narrow down what takes so long to complete the action (is it just a slow network, or is it something in your code? Anyone's guess), so I can't really address the slowness issue. I also don't have a clue which methods are yours versus what you simply get from mailcore2
, but with that said...
NSLog()
statements should almost always be wrapped in #if DEBUG
and #endif
statements.
Moreover, regardless of whether or not the deletion is successfully, we need to let the user know one way or the other, and NSLog()
isn't going to cut it.
I'm not sure how the second code snippet ties to the first, but all of our methods could use better names.
deleteOnServer(indexSet:)
- delete what? on which server? What does index set represent?
createNewIMAPSessionWith
- the words New
and With
can both be removed from this method. Although, what would probably be best is simply creating a factory method:
extension MCOIMAPSession {
class func session(userName: String, hostname: String, oauth2Token: String) -> MCOIMAPSession {
// all the code you're already doing
}
}
And then we call it simply like this:
let imapSession = MCOIMAPSession.session(userName:"username", hostname:"hostname", oauth2Token:"token")
localCopyMessageOperation!.start
This is a pretty big no-no, in my opinion. If the method we're calling to get localCopyMessageOperation
returns an optional, then we should use real optional chaining, not forced unwrapping. It's as simple as changing the exclamation point to a question mark and it prevents an "found nil when unwrapping" (or whatever it's called) exception.