Cocoa: NSURLConnection not attempting an HTTP Request

前端 未结 2 386
无人共我
无人共我 2020-12-19 14:41

I\'ve had significant success with NSURL, NSURL[Mutable]Request, NSURLConnection with my iPhone applications. When trying to compile a stand alone Cocoa application, 10 line

2条回答
  •  忘掉有多难
    2020-12-19 15:09

    The other poster pretty much answered this for you, but I thought I would just add a few things.

    First, you don't really need to link to Cocoa for this, just linking to the Foundation framework is okay. Also, since you don't need a connection to the Window Server, you can get rid of the [NSApplication sharedApplicaiton] call. If you want just a simple, console test application to start with, use what you have now and add this before your [pool realease] call:

    [[NSRunLoop currentRunLoop] run];

    Please note, however, that this will block and may actually never return. Before calling this, you can add a timer if you want your code to actually do something in the background :) See the documentation on NSRunLoop for more ways to use this.

提交回复
热议问题