locked
Methods missing in NSUrlConnectionDelegate RRS feed

  • Question

  • User209 posted

    I am in the middle of migrating libraries to the Unified API, most stuff translates very easily. However, now I am hitting a wall.

    I have a UIViewController displaying a UIWebView, which is used for logging in with Azure Access Control services. When it hits a certain schema it should parse it and notify back that it got the returned token from ACS, otherwise create a new NSUrlConnection which navigates the NSUrlRequest.

    The problem occurs with the NSUrlRequest, which requires an instance of INSUrlConnectionDelegate, where prior to the Unified API I was using NSUrlConnectionDelegate.

    Udating my library to Unified API a couple of methods I was using before are missing. Namely ReceivedData(NSUrlConnection, NSData) and FinishedLoading(NSUrlConnection). What do I do now?

    The code can be seen here, haven't yet pushed the Unified API changes: https://github.com/Cheesebaron/Cheesebaron.MvxPlugins/blob/master/AzureAccessControl/AzureAccessControl.Touch/Views/AccessControlWebAuthController.cs#L131

    Wednesday, January 21, 2015 1:43 PM

Answers

  • User31231 posted

    Hi @Cheesebaron?,

    I just did a quick search of our documentation that shows the differences between the Classic API & Unified API and there has been modifications to the NSUrlConnection class. If you search for NSUrlConnectionDelegate in the above linked doc you'll see the modifications.

    One of the things that was done when we moved from the Classic API to the Unified API was to correct issues in our original mappings and this might have been one of those cases. Anyway looking at the new constructors, it looks like you need to pass the NSUrlConnectionDelegate to the NSUrlConnection during the construction phase.

    As these two new constructors have been added:

        public NSUrlConnection (NSUrlRequest request, INSUrlConnectionDelegate connectionDelegate);
        public NSUrlConnection (NSUrlRequest request, INSUrlConnectionDelegate connectionDelegate, bool startImmediately);
    

    I hope this answers your question.

    Thanks,

    Kevin

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, January 21, 2015 1:59 PM

All replies

  • User31231 posted

    Hi @Cheesebaron?,

    I just did a quick search of our documentation that shows the differences between the Classic API & Unified API and there has been modifications to the NSUrlConnection class. If you search for NSUrlConnectionDelegate in the above linked doc you'll see the modifications.

    One of the things that was done when we moved from the Classic API to the Unified API was to correct issues in our original mappings and this might have been one of those cases. Anyway looking at the new constructors, it looks like you need to pass the NSUrlConnectionDelegate to the NSUrlConnection during the construction phase.

    As these two new constructors have been added:

        public NSUrlConnection (NSUrlRequest request, INSUrlConnectionDelegate connectionDelegate);
        public NSUrlConnection (NSUrlRequest request, INSUrlConnectionDelegate connectionDelegate, bool startImmediately);
    

    I hope this answers your question.

    Thanks,

    Kevin

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, January 21, 2015 1:59 PM
  • User209 posted

    OK, it seems like it has been split into the class NSUrlConnectionDataDelegate. It's great that you are doing this :)

    Wednesday, January 21, 2015 2:01 PM
  • User81238 posted

    @Cheesebaron? Hi can you please share the details how'd you solve this issue. Code snippet will help. Cheers :)

    Thursday, January 22, 2015 11:33 AM
  • User209 posted

    https://github.com/Cheesebaron/Cheesebaron.MvxPlugins/commit/8e57a7cb53f8ec575ad9c48e478e7ab44bcb93a0#diff-d0b47785af23a5a11abceed2acd46b00R131

    Thursday, January 22, 2015 12:05 PM
  • User37356 posted

    I need both NSUrlConnectionDelegate and NSUrlConnectionDataDelegate, to cater to authentication challenge and handle the received response. How do I do this now?

    Monday, June 22, 2015 12:25 PM
  • User139863 posted

    @Joms - did you find a way to do this? I only need to handle the response so only actually need to set-up NSUrlConnectionDataDelegate but can't see how to add this to the connection

    Thursday, January 21, 2016 1:37 PM
  • User139863 posted

    Sorry, I've realised NSUrlConnectionDataDelegate inherits from NSUrlConnectionDelegate so I can just pass my NSUrlConnectionDataDelegate into the NSUrlConnection, making sure I implement all of the relevant methods

    Thursday, January 21, 2016 2:39 PM