Macos Dashcode 3.0,数据源+非表单POST请求?
简单问题:在Dashcode 3.0中,如何告诉数据源发送POST请求,如:Macos Dashcode 3.0,数据源+非表单POST请求?,macos,post,dashcode,Macos,Post,Dashcode,简单问题:在Dashcode 3.0中,如何告诉数据源发送POST请求,如: url: https://example.com/xml method: POST HTTPBody: <?xml version='1.0'?> <request command='list'> <parameter keyword='id' value='trogdor' /> </request
url:
https://example.com/xml
method:
POST
HTTPBody:
<?xml version='1.0'?>
<request command='list'>
<parameter keyword='id' value='trogdor' />
</request>
雪豹中的新Dashcode 3.0非常棒。我对数据源特别感兴趣——在数据源中,您可以提供返回XML或JSON的URL。Dashcode获取数据,然后允许您在响应片段和UI之间绘制连接,这与Interface Builder非常相似
我发现的所有示例都使用HTTP GET请求。但我的提要必须通过POST访问。AjaxController有一个method属性,很容易设置为POST。它还有一个parameters属性,用于模拟基于表单的帖子。问题是,我的请求不是来自表单。我将描述我在Objective-C中所做的工作。我想让它与仪表板和Safari小部件一样工作
NSMutableURLRequest *theRequest=[NSMutableURLRequest
requestWithURL:[NSURL URLWithString:@"https://example.com/xml"]];
[theRequest setHTTPMethod:@"POST"];
NSString *postString =
@"<?xml version='1.0'?><request command='list'><parameter keyword='id' value='trogdor' /></request>";
[theRequest setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
手动操作也可以-我不必使用whiz-bang Dashcode 3.0可视化连接,但这会很有趣。我已经阅读了很多Ajax和JavaScript等内容。似乎大多数场景都假设POST与键/值编码的url一起使用。也许我无法更改的服务器是不稳定的,需要以裸XML形式发布数据,而不是像request=xmlstuff这样更传统的键/值。