小编trl*_*udt的帖子

C中函数'sleep'的正确#include是什么?

我正在使用Big Nerd Ranch书籍Objective-C编程,它首先让我们在前几章中用C语言编写.在我创建的一个程序中,我使用了sleep功能.它在书中告诉我要把它放在#include <stdlib.h>下面#include <stdio.h>.这应该摆脱警告说"隐含声明功能'睡眠'在C99中无效".但是由于某些原因我放#include <stdlib.h>了之后,警告并没有消失.这个问题并没有阻止程序运行良好,但我只是好奇#include我需要使用它!

c sleep

104
推荐指数
5
解决办法
35万
查看次数

导航栏或ToolBar在xcode中出现问题

好的我正在看iPhone iCal应用程序,并且好奇顶部栏是导航栏还是工具栏?香港专业教育学院尝试使用两者,但我也无法弄清楚如何改变按钮的大小,就像右上角的+按钮一样小...非常困惑..我假设它的导航栏,但当我阅读导航栏的说明,它说每当你要在栏上添加一个按钮或项目时,你就无法直接连接它......不知道怎么做...但是有人想帮忙解决这个问题吗?

xcode objective-c

3
推荐指数
1
解决办法
1023
查看次数

使用 Google Maps API 在 Swift 3 中查找 2 个位置之间的驾驶/步行距离

我正在尝试使用 Google Maps API 获取两个位置之间的驾驶/步行距离。我正在将我的应用程序从 Objective-c 更新到 Swift 3,现在我坚持将这段代码转换为 Swift 3。

NSString *dist;
NSString *strUrl = [NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/directions/json?origin=%f,%f&destination=%f,%f&sensor=false&mode=%@", closestLocation.coordinate.latitude,  closestLocation.coordinate.longitude, _currentUserLocation.coordinate.latitude,  _currentUserLocation.coordinate.longitude, @"DRIVING"];
NSURL *url = [NSURL URLWithString:[strUrl stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet]];
NSData *jsonData = [NSData dataWithContentsOfURL:url];
if(jsonData != nil)
{
    NSError *error = nil;
    id result = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
    NSMutableArray *arrDistance=[result objectForKey:@"routes"];
    if ([arrDistance count]==0) {
        NSLog(@"N.A.");
    }
    else{
        NSMutableArray *arrLeg=[[arrDistance objectAtIndex:0]objectForKey:@"legs"];
        NSMutableDictionary *dictleg=[arrLeg objectAtIndex:0];

        dist = [NSString stringWithFormat:@"%@",[[dictleg   objectForKey:@"distance"] objectForKey:@"text"]];
    }
}
else{
    NSLog(@"N.A.");
}
Run Code Online (Sandbox Code Playgroud)

我尝试使用像 Swiftify 这样的工具,但到处都是错误。我现在拥有的是:

var …
Run Code Online (Sandbox Code Playgroud)

google-maps swift swift3

2
推荐指数
1
解决办法
1642
查看次数

标签 统计

c ×1

google-maps ×1

objective-c ×1

sleep ×1

swift ×1

swift3 ×1

xcode ×1