Beginner Networking question

Discussion in 'Mac Programming' started by shadowfaux, May 25, 2008.

  1. shadowfaux macrumors newbie

    Joined:
    May 19, 2008
    #1
    I'm trying to get used to the networking API Apple provides so I thought I'd try to write a simple wrapper around the NSURL* classes. It works fine for synchronous page retrieval but it's not working for the asynchronous bit and I can't seem to figure out what's going wrong.

    Can somebody take a look at it and see if you can identify what I'm screwing up?

    calling code: http://rafb.net/p/pKe8oB43.html
    NSURLConnection wrapper code: http://rafb.net/p/cv6eMC23.html

    NSLog output: http://rafb.net/p/uRyDcG38.html

    thanks
    -sf
     
  2. cmaier macrumors G3

    Joined:
    Jul 25, 2007
    Location:
    California
    #2
    Something is missing from this sentence?
     
  3. shadowfaux thread starter macrumors newbie

    Joined:
    May 19, 2008
    #3
    fair point, edited original post
     
  4. cmaier macrumors G3

    Joined:
    Jul 25, 2007
    Location:
    California
    #4
    You say it isn't working; what are the symptoms?
     
  5. shadowfaux thread starter macrumors newbie

    Joined:
    May 19, 2008
    #5
    Take a look at the output from the NSLog statements ( http://rafb.net/p/uRyDcG38.html ). If you compare that to the ManagedConnection class and the logging statements within you'll see that connection:didReceiveResponse: is not called and that connection:willCacheResponse: is.

    Checking the docs associated with NSURLConnection I find the following two statements:

    "Zero or more connection:didReceiveResponse: messages will be sent to the delegate before receiving a connection:didReceiveData: message. The only case where connection:didReceiveResponse: is not sent to a delegate is when the protocol implementation encounters an error before a response could be created."
    and
    "Zero or one connection:willCacheResponse: messages will be sent to the delegate after connection:didReceiveData: is sent but before a connectionDidFinishLoading: message is sent."

    To me this seems to mean that something is broken because not getting a connection:didReceiveResponse: sounds like I should be getting an error on the connection attempt. Also, the wording of connection:willCacheResponse: implise that it only gets called after connection:didReceiveData: which is not getting called for me.

    Does that make a bit more sense? sorry I wasn't more clear up above. If it's still unclear what's got me confused feel free to ask, I'm at wits end here and pretty sure it's some newbie mistake that's staring me in the face =/
     

Share This Page