我正在使用MapKit api获取地图上的当前位置,并在两个位置指针之间绘制路线.我还希望获得其路线之间的所有主要站点.我使用下面的函数来获取两个位置之间的路由
- (NSArray*)getRoutePointFrom:(MyLocation*)origin to:(MyLocation*)destination
{
NSString* saddr = [NSString stringWithFormat:@"%f,%f", origin.coordinate.latitude, origin.coordinate.longitude];
NSString* daddr = [NSString stringWithFormat:@"%f,%f", destination.coordinate.latitude, destination.coordinate.longitude];
NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/directions/json?origin=%@&destination=%@&sensor=false&avoid=highways&mode=driving",saddr,daddr]];
NSError *error=nil;
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ;
[request setURL:url];
[request setHTTPMethod:@"POST"];
NSURLResponse *response = nil;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error: &error];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
SBJsonParser *json=[[SBJsonParser alloc] init];
NSDictionary *dic=[json objectWithString:responseString error:nil];
NSDictionary *nextdic=[dic valueForKey:@"routes"];
NSDictionary *legdic=[nextdic valueForKey:@"legs"];
NSDictionary *stepdic=[legdic valueForKey:@"steps"];
NSArray *array=[[NSArray alloc] initWithArray:[[stepdic valueForKey:@"polyline"] valueForKey:@"points"]];
NSString …Run Code Online (Sandbox Code Playgroud) 我使用以下代码来覆盖该console.log函数,因为我只想console.log在showConsole返回时打印true.
var proxyConsolelog = window.console.log;
console.log=function(msg){
try{
if(Boolean(showConsole))
{
proxyConsolelog(msg);
}
}catch(e){
alert(JSON.stringify(e.message));
proxyConsolelog('ERROR-->>'+e.message);
}
}
Run Code Online (Sandbox Code Playgroud)
该proxyConsolelog行会产生问题,并alert(JSON.stringify(e.message));给我一个"类型错误".
我得到了这个:
void SendDelegateMessage(NSInvocation*):委托(webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame :)在等待10秒后无法返回.主运行循环模式:kCFRunLoopDefaultMode
在日志中.
我怎样才能做到这一点?
我想自定义EKEventEditViewController,使其URL和NOTES字段禁用或删除它.作为EKEventEditViewController的默认接口.我无法自己定制,我搜索了很多,并没有找到任何可行的解决方案.任何人都使用过这样的场景.请详细说明问题.
我已经在我的项目中实现了套接字连接,并且工作正常。但是我的问题是我想在套接字打开完成时发送一个字符串请求。
代表工作正常。
- (void)initNetworkCommunication
{
lastString=@"";
isSocketAuthorized=NO;
NSLog(@"$$$$$$$$$$$$$$$$$$$$$$$$$============socket connection INITIALISED....");
CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
CFStreamCreatePairWithSocketToHost(NULL,(CFStringRef)@"XXX.XX.XXX.XX",XXXX, &readStream, &writeStream);
inputStream = (__bridge NSInputStream *)readStream;
outputStream = (__bridge NSOutputStream *)writeStream;
[inputStream setDelegate:self];
[outputStream setDelegate:self];
[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[inputStream open];
[outputStream open];
}
- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode
{
switch (eventCode) {
case NSStreamEventOpenCompleted:{
NSLog(@"Stream opened");
[self performSelectorInBackground:@selector(sendAuthRequest) withObject:nil];
}
break;
case NSStreamEventHasBytesAvailable:
{
if (aStream == inputStream) {
uint8_t buffer[1024];
int len;
while ([inputStream hasBytesAvailable]) {
len = [inputStream …Run Code Online (Sandbox Code Playgroud) ios ×2
iphone ×2
cordova ×1
eventkit ×1
ios5 ×1
javascript ×1
jquery ×1
mapkit ×1
objective-c ×1
sockets ×1