字典不能转换为Void

嗨,大家好我一直在寻找网没有太多的运气,但我试图绕过Alamofiresasynchronous性。 我试图返回作为字典的JSON响应,但Xcode是给我“字典不能转换为'虚空'” func homePageDetails(userName:String) -> (Dictionary<String,AnyObject>){ let username = userName let hompePageDetails = Alamofire.request(.GET, "http://example.com/API/Bunch/GetHomePageDetails/\(username)/").responseJSON{(request, response, JSON, error) in print(JSON) var test = JSON as Dictionary<String,AnyObject> return test } } 任何帮助将不胜感激。

iOS Swift:如何使用TwitterKit将video发布到Twitter?

我没有find相关的和最新的答案。 这是我目前正在使用的代码,所有的请求处理正确,但没有video张贴? if let userID = Twitter.sharedInstance().sessionStore.session()?.userID { var client = TWTRAPIClient(userID: userID) let text: String = "Testing Video" let videoLength: String = "\(self.video.length)" print(videoLength) var initError: NSError? var message = ["status": text, "command" : "INIT", "media_type" : "video/m4v", "total_bytes" : videoLength] let preparedRequest: NSURLRequest = client.URLRequestWithMethod("POST", URL: self.strUploadUrl, parameters: message, error: &initError) client.sendTwitterRequest(preparedRequest, completion: […]

确定iOS设备上可能同时触摸的最大数量?

有没有办法找出iOS设备(iPhone,iPod Touch,iPad)上同时触摸的最大数量? 我已经在这里和那里看到,iPhone可以处理5,而iPad可以处理11,但我没有find官方的方式(通过函数调用,说)来确认这一点。

iPhone 4有一个绝对确定的方式来长期NSTimer火灾

我一直有我的NSTimers和背景select器的麻烦。 这是让我疯狂,需要很长时间来尝试每一个调整。 为了保持我的理智,以及后代cocoa程序员的理智,我问了这个问题: 有一个绝对100%的可靠的方法来让一个定时的,长期的计时器在晚些时候触发,而不pipe它是从后台线程,主线程等调用的吗? 似乎我一直都不得不一遍一遍地解决使用NSTimers的大多数类的相同的问题。 他们在短期testing期间工作,比方说,我设置定时器通过后台线程在10秒内触发。 它工作,因为仍然有运行循环运行。 但是,一旦我把火灾时间改变到了我真正想要的时间,比如15-30分钟,就有了沉默。 运行循环已经结束,我不知道如何处理这种情况。 什么都没有发生,几天后我发现了这样的错误,一旦我已经忘记了哪个计时器会对此负责。 目前,我正在用select器做一些非常非常难看的舞蹈,例如这里有一个testing方法(它似乎适用于10分钟的定时器): //this is a test method to simulate a background task requesting a timer [self performSelectorInBackground:@selector(backgroundReminderLongTermTest:) withObject:nil]; //this is a method similar to the one that the background thread would be trying to invoke -(void)backgroundReminderLongTermTest:(id)sender { [self performSelectorOnMainThread:@selector(backgroundReminderFromMainThread:) withObject:nil waitUntilDone:NO]; } //this is a wrapper […]

iOS7 – 是否可以更改状态栏的颜色?

有谁知道如何改变状态栏的文字颜色? 我想要它橙色。 我不是在谈论常规的黑色或白色的颜色UIStatusBarStyleLightContent ; 或者UIStatusBarStyleBlackOpaque ; pipe他呢。

在ios中推送通知

我是一个新的PHP和编写代码推送通知CodeGo.net,但我得到了这些erros。 这是我的模特 function sendmessage($appid, $deviceid, $status, $message) { $deviceToken = '0f744707bebcf74f9b7c25d48e3358945f6aa01da5ddb387462c7eaf61bbad78'; $message = 'My first push notification!'; $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem'); //stream_context_set_option($ctx, 'ssl', 'passphrase', 'essar@123'); $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx); if (!$fp){ exit("Failed to connect: $err $errstr" . PHP_EOL); } else { print "Connection OK/n"; } echo 'Connected to […]

在iOS中存储和执行大量的操作

我怎样才能处理操作,如:48534588306961133067968196965257961415756656521818848750723547477673457670019632882524164647651492025728980571833579341743988603191694784406703 没有什么,我已经尝试了迄今为止…无符号长,长期等等…

Objective-C中的严格types检查第2部分

在这个问题中,我正在寻找一种方法来确保variables是使用define定义的某种types。 但有时候我有这种情况: – (void) theSituation:(Thinger*)thinger { ASSERT_IS_KIND_OF(thinger, Thinger); // etc. etc. 然后我开始思考,只是为了debugging目的 ,可能会很高兴能够调用类似于: – (void) theSituation:(Thinger*)thinger { ASSERT_INPUT_PARAMS_ARE_OF_CORRECT_TYPES(); // etc. etc. 问题是:你可以通过#define检查一个方法的参数是否正确(使用isKindOf ),你将如何做(一般来说)?

没有调用MKMapView MKPointAnnotation点击事件

我正在使用MKPointAnnotation MKMapView(委托设置正确)。 注释是在后台线程调用的这个方法中生成的。 func updateMapAnnotations() { for var i = 0; i < DataManager.getStationList().count; i++ { var s = DataManager.getStationList()[i] as Station var annotation = MKPointAnnotation() annotation.setCoordinate(CLLocationCoordinate2D(latitude: s.latitude, longitude: s.longitude)) annotation.title = "\(s.id)" dispatch_async(dispatch_get_main_queue(), { self.mapView.addAnnotation(annotation) }) } } 注解视图在这里生成: func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! { if (annotation is MKUserLocation) { return […]

与iOS应用程序共享与facebook的超链接

我可以使用以下代码与Facebook分享文字,图片和url。 _lblTitle.text=@"Joe just ran 3.10 miles on the Niagara Falls 5k in 24.53 with http://www.outsideinteractive.com"; NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: _lblTitle.text, @"name", data, @"picture", nil]; // Make the request [FBRequestConnection startWithGraphPath:@"/me/photos" parameters:params HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { if (!error) { // Link posted successfully to Facebook NSLog([NSString stringWithFormat:@"result: %@", result]); } else […]