我想允许无效的SSL证书.我的主要代码如下:
myClient = [[MyClient alloc] init];
[myClient getHtml:@"/path/to/the/distination.html"];
Run Code Online (Sandbox Code Playgroud)
MyClient类代码如下:
#import <Foundation/Foundation.h>
#import "AFNetworking.h"
@interface MyClient : NSObject
- (void)getHtml:(NSString *)path;
@end
#define _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_
@implementation MyClient
- (void)getHtml:(NSString *)path
{
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"https://trusted.server.net"]];
[httpClient getPath:path parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"%@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error = %@", error);
}];
}
@end
Run Code Online (Sandbox Code Playgroud)
我阅读下面的页面并尝试了宏但这不起作用.
自签名证书SSL·问题#189·AFNetworking/AFNetworking https://github.com/AFNetworking/AFNetworking/issues/189
请帮我...
我正在使用Jasmine,我想测试一个对象是否有某种方法,如下所示:
it "should have 'open' method", ->
@xhr = ajax.create()
expect(@xhr).toHaveMethod "open" # I want to test like this!
Run Code Online (Sandbox Code Playgroud)
我怎么测试?谢谢你的好心.
我想在PhantomJS的控制台中测试我的JS代码,它使用Jasmine的jQuery,但是 ReferenceError: Can't find variable: $
我可以在浏览器中正常测试Jasmine的代码.
谢谢您的帮助.
$ phantomjs examples/run-jasmine.js http://localhost:8888/
ReferenceError: Can't find variable: $
http://localhost:8888/public/javascripts/PhotoTable.js:59
ReferenceError: Can't find variable: $
http://localhost:8888/public/javascripts/PhotoTable2.js:129
ReferenceError: Can't find variable: $
http://localhost:8888/public/javascripts/amenimomakezu.js:18
http://localhost:8888/public/javascripts/amenimomakezu.js:20
ReferenceError: Can't find variable: _error
http://localhost:8888/public/javascripts/p121106.js:29
http://localhost:8888/public/javascripts/p121106.js:39
null
Data loaded [object Object]
Data loaded [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Data loaded [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object …Run Code Online (Sandbox Code Playgroud) 我试图从Apple主页获取 HTML.
AFHTTPRequestOperationManager *manager
= [AFHTTPRequestOperationManager manager];
[manager GET:@"http://www.apple.com/jp" parameters:nil
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"HTML: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
Run Code Online (Sandbox Code Playgroud)
此失败,错误消息如下:
2014-02-07 14:54:22.922 Tests[1833:70b] Error: Error Domain=AFNetworkingErrorDomain Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo=0x8a32650 {NSErrorFailingURLKey=http://www.apple.com/jp/, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0xea2e1a0> { URL: http://www.apple.com/jp/ } { status code: 200, headers {
"Accept-Ranges" = bytes;
"Cache-Control" = "max-age=237";
Connection = "keep-alive";
"Content-Encoding" = gzip;
"Content-Length" = 4402;
"Content-Type" = "text/html; charset=UTF-8";
Date = "Fri, 07 Feb …Run Code Online (Sandbox Code Playgroud) 是否可以控制segue速度?
我已经检查了文档,但Apple没有给出任何方法.
但我更多的是寻找破解和改变低级代码的想法,以便在慢动作中进行猜测.
我使用UISwipeGestureRecognizer和我覆盖
-(void)touchesBegan...,-(void)touchesEnded...,-(void)touchesMoved... methods.
Run Code Online (Sandbox Code Playgroud)
似乎touchesBegan和touchesMoved保持跟踪触摸,直到Swipe Gesture识别并且touchesEnded未被调用(与touchesCancelled相同).但我需要轻扫手势识别器和触摸器才能完成这项工作,我该怎么做呢?
对不起,我不太了解Objective-C.
这是SomeClass.h:
@interface SomeClass : NSObject
@property NSString *property;
@end
Run Code Online (Sandbox Code Playgroud)
我们可以property在SomeClass.m中使用它们
self.property
和
_property.
我应该使用哪个?
是否有某种情况决定使用哪种方式?
谢谢您的帮助.
我想要无头地测试,但我不能那样做.
以下代码启动chrome浏览器.不是无头.好.
// test.js
var webdriverio = require('webdriverio');
var options = {
desiredCapabilities: {
browserName: 'chrome'
}
};
webdriverio
.remote(options)
.init()
.url('http://www.google.com')
.title(function(err, res) {
console.log('Title was: ' + res.value);
})
.end();
Run Code Online (Sandbox Code Playgroud)
下面的代码(摩卡测试代码)不启动Chrome浏览器的$ mocha test.js.
无头.NG.
但测试通过了!我不明白这.
我检查了Selenium Server的日志,但它没有显示(左)任何日志.没有踪影.
// test-mocha.js
var expect = require('expect.js');
var webdriverio = require('webdriverio');
var options = {
desiredCapabilities: {
browserName: 'chrome'
}
};
describe('WebdriverIO Sample Test', function () {
it('should return …Run Code Online (Sandbox Code Playgroud) 我刚开始学习Haxe,但我遇到了编译错误.
Main.hx
package helloworld;
import js.Lib;
class Main {
static function main() {
Lib.alert("Hello World");
}
}
Run Code Online (Sandbox Code Playgroud)
目标类请注意helloworld.Main.
build.hxml
-js bin/HelloWorld.js
-cp src
-main helloworld.Main
-debug
Run Code Online (Sandbox Code Playgroud)
构建流程日志
Building HelloWorld_p140627
Running Pre-Build Command Line...
cmd: C:\HaxeToolkit\haxe\haxe.exe X:\tmp\HelloWorld_p140627\build.hxml
Class not found : helloworld.Main
Build halted with errors.
Done(1)
Run Code Online (Sandbox Code Playgroud)

为什么?这门课helloworld.Main肯定存在.我甚至不能说"你好,世界"?
我想知道为什么NSURL类存在.我认为下面的代码毫无意义.
NSURL *url = [NSURL URLWithString:@"http://www.apple.co.jp/"];
NSError* error = [[NSError alloc] init];
NSString* content = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error];
Run Code Online (Sandbox Code Playgroud)
为什么不允许下面的代码?
NSError* error = [[NSError alloc] init];
NSString* content = [NSString stringWithContentsOfURL:@"http://www.apple.co.jp/" encoding:NSUTF8StringEncoding error:&error];
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助.
objective-c ×6
javascript ×3
afnetworking ×2
jasmine ×2
coffeescript ×1
guard ×1
haxe ×1
ios ×1
jquery ×1
mocha.js ×1
phantomjs ×1
segue ×1
selenium ×1
uistoryboard ×1
webdriver ×1
webdriver-io ×1