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

Add defaultURLSession and its delegate instead of instancePair #14

Merged
merged 6 commits into from
Mar 20, 2015

Conversation

ishkawa
Copy link
Owner

@ishkawa ishkawa commented Mar 16, 2015

This resolves #13. This change makes implementation simpler and more obvious.

  • Add defaultURLSession that has a delegate with minimal implementation of NSURLSessionDataDelegate.
  • Remove instance pair, which is singleton instance pair of API and NSURLSession.

Breaking changes:

  • API does not creates singleton instances for each API subclasses. If an API subclass needs a separated session, defaultURLSession should be overrided.
  • API.instance is no longer available.
  • API.session is no longer available.
  • Delegate methods implemented in API should be moved to custom delegate class, and its instance should be set to delegate of defaultURLSession.

See the discussion on #13 for more details.

@ishkawa ishkawa modified the milestone: 0.4 Mar 17, 2015
@ishkawa ishkawa changed the title [WIP] Add defaultURLSession and its delegate instead of instancePair Add defaultURLSession and its delegate instead of instancePair Mar 17, 2015
@ishkawa
Copy link
Owner Author

ishkawa commented Mar 17, 2015

@ikesyo @garnett This is ready for review.

@@ -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
Copy link
Collaborator

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.

Copy link
Owner Author

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.

@ikesyo
Copy link
Collaborator

ikesyo commented Mar 18, 2015

Needs merging base branch into this branch to resolve conflict.

@ishkawa
Copy link
Owner Author

ishkawa commented Mar 18, 2015

Oh, I have just merged base branch.

@ishkawa
Copy link
Owner Author

ishkawa commented Mar 20, 2015

Is it okay to merge this and release 0.4?

@ikesyo
Copy link
Collaborator

ikesyo commented Mar 20, 2015

I'm OK, good to go :shipit:

@ishkawa
Copy link
Owner Author

ishkawa commented Mar 20, 2015

㊗️

ishkawa added a commit that referenced this pull request Mar 20, 2015
Add defaultURLSession and its delegate instead of instancePair
@ishkawa ishkawa merged commit d6d02cf into develop/0.4 Mar 20, 2015
@ishkawa ishkawa deleted the feature/no-singleton-API-instance branch March 20, 2015 03:52
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.

2 participants