Question about NSURLConnection

Discussion in 'iOS Programming' started by webznz, Mar 8, 2011.

  1. webznz macrumors member

    Joined:
    Mar 8, 2011
    Location:
    Hobbitin
    #1
    Hi, I am graduate developer and am looking for help on this simple application I'm making.

    My question is, is it possible to supply a user name and password along with the NSURLconnection request when trying to connect to a database that requires a login.

    if so are there any examples you could provide me with. Any help would be greatly appreciated.
     
  2. ulbador macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #2
    That has nothing to do with NSURLConnection, that's entirely within the HTTP spec.


    Code:
    http://username:password@www.myhost.com/aDirectory/aFile.php?aRequestParam=S
     
  3. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    That will depend on how the login works. In general your delegate will get messages like connection:didReceiveAuthenticationChallenge: when a username/password challenge is received. I don't do examples: I would expect any graduate to be able to write code from the documentation.
     
  4. ulbador macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #4
    Ha, didn't even think about this. I just recently had to do something like this quick and dirty like for an inhouse reporting app, and the easiest way was as I mentioned above.

    To the OP, doing it as robbie mentions is the FAR superior way.
     
  5. webznz thread starter macrumors member

    Joined:
    Mar 8, 2011
    Location:
    Hobbitin
    #5
    Thank you for the responses. Robbie, I am extremely new to objective C and iOS frameworks. I know I need to get better but I am doing my best, and would hope people would understand.
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    I do understand. But in my experience of trying to help people, both on these forums and as a lab demonstrator when I was at University, I have seen that giving people examples teaches them absolutely nothing. They copy and paste and don't know anything about what they have copied.

    My suggestion: try stuff. When it doesn't work post your code, explain why you have done what you have done, explain what outcome you expected and what happened. Then you can be helped.
     
  7. webznz thread starter macrumors member

    Joined:
    Mar 8, 2011
    Location:
    Hobbitin
    #7

    Yes it is a good option from the research I have done, and was going to be my option of choice. But when I approached the database administrator for this application I am making he said that authentication challenge is not an option. But I am going to go back and talk to him about this because IMO it's the most secure...
     
  8. webznz thread starter macrumors member

    Joined:
    Mar 8, 2011
    Location:
    Hobbitin
    #8
    Yep fair enough, I defiantly want to learn and understand what I am doing. And I know of the people you talk about :) never... never do group assignments with people like that, not unsless you are keen to do all the work yourself. lol
     
  9. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #9
    I would ask him to provide details on the login protocol. It sounds like the login is not running at the HTTP level so you will be doing all the login work yourself, rather than Apple's classes. Or you might be able to get an off-the shelf library that provides connectivity with login etc.
     
  10. webznz thread starter macrumors member

    Joined:
    Mar 8, 2011
    Location:
    Hobbitin
    #10
    Yea, I need to pin him down and show him whats going on with the code.
    I think the problem is He dose not understand what I'm doing and I don't understand what he requires of me. Think I better go talk to him again
     
  11. webznz thread starter macrumors member

    Joined:
    Mar 8, 2011
    Location:
    Hobbitin
  12. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #12
    There are several examples related to networking from Apple. Look at SimpleURLConnections and AdvancedURLConnections and maybe some others.
     

Share This Page