ios - 如何在ios中发送多个参数?
<p><p>如何发送<code>json</code>格式的参数?</p>
<p><strong>以下是我的输入参数:</strong></p>
<pre><code>[
{
"LoginID":151,
"UserID":0,
"SubUserID":0,
"WorkGroupID":92,
"WorksFor":"Doctor",
"UserWorkGroup":0
},
{
"SortingName":"",
"Searching":true,
"SortingOrder":"Desc",
"RecordsCount":10,
"PageIndex":0
}
]
</code></pre>
<p><strong>之前我发送的参数如下:</strong></p>
<pre><code> initWithObjectsAndKeys:@"55",@"LoginID",@"0",@"UserID",@"0",@"SubUserID",@"90",@"WorkGroupID",@"Doctor",@"WorksFor",@"0",@"UserWorkGroup",nil] andRequestType:@"POST"];
</code></pre>
<p>如何像这样发送,但现在我需要添加上面提到的更多输入?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>只需使用以下代码..</p>
<pre><code>NSMutableArray * myArray = [init];
NSMutableDictionary * myData = [init];
;
;
;
;
;
;
;
myData = [init];
;
;
;
;
;
;
NSData *jsonData2 = ;
NSString *jsonString = [ initWithData:jsonData2 encoding:NSUTF8StringEncoding];
NSLog(@"Your final jsonData as string:\n%@", jsonString);
</code></pre>
<p>如果您想将此数据发送到服务器,那么您可以使用此代码:</p>
<pre><code>NSData *dataToSend = ;
initWithObjectsAndKeys:dataToSend] andRequestType:@"POST"];
</code></pre></p>
<p style="font-size: 20px;">关于ios - 如何在ios中发送多个参数?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/36995718/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/36995718/
</a>
</p>
页:
[1]