Using NSUrl for xml http get

Discussion in 'Mac Programming' started by ltt, Sep 22, 2009.

  1. ltt macrumors newbie

    Sep 22, 2009

    I am a new Objective-C Developer with mild C and Delphi experience. I am finding it hard to adapt to Objective-C. I can see the benefits, but I am still getting my head around the syntax.

    I have what I consider a really simple app to write but I can not for the life of me work out how to do it! Can anyone help?
    I believe I need to use NSUrl somehow.

    The requirement;

    I need to send an XML request to a specific url and do a http get, then write the results to a file. An example request and result is shown below.

    An example request would be:

    <request method="[method name]">
    <!-- method arguments -->

    I expect a successful response like;

    <response status="ok">
    <!-- return value(s) here] -->

    I need to write the returned values to a file.

    Unsucessful response like;

    <response status="fail">
    <error> ... </error>

    I need to display the error message to NSLog.

    I can use curl to get the response using the following command;
    curl -u insert_token_here:X -d '[xml body here]

    Thanks in advance. Comments would be great to I can learn from your response.

  2. ltt thread starter macrumors newbie

    Sep 22, 2009
    general tips?

    I know its a very specific request, but if no one has an example function, is there any way someone could give me some steps/pointers?

    How can I get NSURL to send a request and accept data?

    What functions/properties of NSURL do I need to research?

  3. chown33 macrumors 604

    Aug 9, 2009
    What have you tried?

    Have you done any research at all on NSURL? Have you read the programming guide? The class reference?

    There are several links to sample code in the NSURL class reference? Have you looked at those?

    If you're more experienced with C, and your goal is to solve a problem rather than learn about NSURL, then maybe you should use libcurl to get your data.

Share This Page