iphone - 如何从 JSON 输出中分离纬度和经度值?
<p><p>我正在尝试两个位置之间的两条绘制路线,为此我从 Google Map API Web Service 获取所有点。(<code>JSON</code> 输出格式)。在解析 <code>JSON</code> 数据和解码点后,我将所有点存储在 <code>NSMutableArray</code> 上。
每个索引数组都包含这种类型的值。</p>
<pre><code>"<+10.90180969, +76.19167328> +/- 0.00m (speed -1.00 mps / course -1.00) @ 12/04/12 10:18:10 AM India Standard Time",
</code></pre>
<p>现在我想分离纬度和经度值。 </p>
<pre><code>latitude: +10.90180969
longitude : +76.19167328
</code></pre>
<p>如何从数组的每个索引中获取这些值?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>这只是一种方法。</p>
<pre><code>NSString* str = @"<+10.90180969, +76.19167328> +/- 0.00m (speed -1.00 mps / course -1.00) @ 12/04/12 10:18:10 AM India Standard Time";//you already have this string.
str = (NSString*)[ objectAtIndex:0];
// after above performed step, str equals "<+10.90180969, +76.19167328"
str = ;
// after above performed step, str equals "+10.90180969, +76.19167328"
NSString* strLat = (NSString*)[ objectAtIndex:0];
NSString* strLon = (NSString*)[ objectAtIndex:1];
// after above performed step, strLat equals "+10.90180969"
// after above performed step, strLon equals " +76.19167328"
strLon = ;//<-- to remove the extra space at index=0
</code></pre></p>
<p style="font-size: 20px;">关于iphone - 如何从 JSON 输出中分离纬度和经度值?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/10117738/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/10117738/
</a>
</p>
页:
[1]