-
Notifications
You must be signed in to change notification settings - Fork 205
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
Add defaultURLSession and its delegate instead of instancePair #14
Conversation
@@ -146,13 +111,17 @@ public class API: NSObject, NSURLSessionDelegate, NSURLSessionDataDelegate { | |||
} | |||
} | |||
|
|||
// send request and build response object | |||
// this methods can be removed in Swift 1.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is needed for Swift 1.1? If this is really required, it could be better to omit the default parameter value from the overloaded method, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Swift 1.1, func send(request:URLSession(=default):handler(=default):)
can't omit URLSession
argument with trailing closure. On the other hand, we can omit it in Swift 1.2. Considering our opinions, following methods are suitable for each versions of Swift.
In Swift 1.1:
func send(request:handler(=default):)
func send(request:URLSession:handler(=default):)
In Swift 1.2:
func send(request:URLSession(=default):handler(=default):)
I will leave a comment about this in code.
Needs merging base branch into this branch to resolve conflict. |
Oh, I have just merged base branch. |
Is it okay to merge this and release 0.4? |
I'm OK, good to go |
㊗️ |
Add defaultURLSession and its delegate instead of instancePair
This resolves #13. This change makes implementation simpler and more obvious.
Breaking changes:
API
does not creates singleton instances for each API subclasses. If anAPI
subclass needs a separated session,defaultURLSession
should be overrided.API.instance
is no longer available.API.session
is no longer available.API
should be moved to custom delegate class, and its instance should be set to delegate ofdefaultURLSession
.See the discussion on #13 for more details.