Is there a trick to using an iterator with a subclass?

  1. 5 days ago

    Jason T

    Nov 6 Pre-Release Testers, Xojo Pro Sydney, Australia

    I have a subclass of URLConnection. I want to get the new URLConnection ResponseHeaders property like this from the documentation:

    Dim connection As New URLConnection
    
    Var headers() As String
    For Each header As String In connection.ResponseHeaders
      headers.AddRow(header)
    Next

    The problem is, when I try to access myURLConnection.ResponseHeaders and iterate through the strings as per the documentation code, I get a TypeMismatchException. If I declare a regular URLConnection as per the sample code then it works as it should.

    My guess is that I might need to do something differently to access the ResponseHeaders property given that I have subclassed URLConnection?

    Bug in the docs, they should be Pairs, it only seems to work (by not breaking) as there is nothing in the list in that example.

    Try

    Var connection As New URLConnection
    
    Var s As String = connection.SendSync("GET", "https://www.google.com/", 5)
    
    Var headers() As Pair
    For Each header As Pair In connection.ResponseHeaders
      headers.AddRow(header)
    Next
  2. Julian S

    Nov 6 Pre-Release Testers, Xojo Pro Answer UK
    Edited 5 days ago

    Bug in the docs, they should be Pairs, it only seems to work (by not breaking) as there is nothing in the list in that example.

    Try

    Var connection As New URLConnection
    
    Var s As String = connection.SendSync("GET", "https://www.google.com/", 5)
    
    Var headers() As Pair
    For Each header As Pair In connection.ResponseHeaders
      headers.AddRow(header)
    Next
  3. Jason T

    Nov 6 Pre-Release Testers, Xojo Pro Sydney, Australia

    Perfect. Thank you Julian! :)

or Sign Up to reply!