代码之家  ›  专栏  ›  技术社区  ›  slothbear

Dashcode 3.0,数据源+非表单POST请求?

  •  1
  • slothbear  · 技术社区  · 15 年前

    简单的问题:在DashCode3.0中,如何让数据源发送POST请求,如:

      url:
         https://example.com/xml
      method:
         POST
      HTTPBody:
         <?xml version='1.0'?>
         <request command='list'>
            <parameter keyword='id' value='trogdor' />
         </request>
    

    雪豹中的新dashcode3.0非常棒。我对“数据源”特别感兴趣——在这里可以提供返回XML或JSON的URL。Dashcode获取数据,然后允许您在响应片段和UI之间绘制连接—非常类似于Interface Builder。

      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可视化连接,但会很有趣。

    0 回复  |  直到 12 年前
    推荐文章