iphone如何在向服务器iphone发出请求时将数组作为参数传递

时间:2012-07-12 02:16:18

标签: iphone nsurlrequest

鉴于

a chunk of books and each book will associated with unique id

情景

user can order more than one book

目标

   making an NSMutableURLRequest and send this request to server and let server know which books 
    are being picked 

问题

  For example, user A will choose 3 books whose id are a, b ,c. How can I send an array 
  containing with these id in the request so that server can know that user A are ordering these books

1 个答案:

答案 0 :(得分:1)

取决于您的服务器所期望的格式,例如,如果您使用RESTful,那么您必须在post或get之间进行选择并基于该构建查询。如果你确实使用restful,那么使用RestKit API并使用params属性。 (或者您可以使用基本的ios api直接构建它们)。您也可以以JSON格式发送数据,但服务器必须知道如何解析它。