我正在尝试针对Chrome运行我的Selenium测试.当我在本地初始化驱动程序时:
@driver = Selenium::WebDriver.for( :chrome )
Run Code Online (Sandbox Code Playgroud)
一切正常(我已将Chrome二进制文件放在我的PATH上)但是当我尝试远程启动时:
@driver = Selenium::WebDriver.for(:remote, :url => 'http://' + SELENIUM_HOST + port + webdriver_hub, :desired_capabilities => :chrome)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
Selenium :: WebDriver :: Error :: UnhandledError:chromedriver可执行文件的路径必须由webdriver.chrome.driver系统属性设置; 有关详细信息,请参阅 http://code.google.com/p/selenium/wiki/ChromeDriver.最新版本可以从http://code.google.com/p/chromium/downloads/list下载 (java.lang.IllegalStateException)
我在那里有点困惑 - 我究竟应该如何设置这个系统属性?我发现这个代码用Java编写:
DesiredCapabilities caps = DesiredCapabilities.chrome();
caps.setJavascriptEnabled(true);
caps.setCapability("chrome.binary", "/path/to/where/chrome/is/installed/chrome.exe");
System.setProperty("webdriver.chrome.driver","/path/to/where/you/ve/put/chromedriver.exe");
ChromeDriver driver = new ChromeDriver(caps);
Run Code Online (Sandbox Code Playgroud)
但我的测试是用Ruby编写的.RubyBindings没有谈论这个问题 http://code.google.com/p/selenium/wiki/RubyBindings
我是iOS新手,我UIPanGestureRecognizer
在我的项目中使用.在我有一个要求得到当前触摸点和之前的触摸点,当我拖着视图.我正在努力争取这两点.
如果我使用touchesBegan
方法而不是使用UIPanGestureRecognizer
,我可以通过以下代码得到这两点:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
CGPoint touchPoint = [[touches anyObject] locationInView:self];
CGPoint previous=[[touches anyObject]previousLocationInView:self];
}
Run Code Online (Sandbox Code Playgroud)
我需要在UIPanGestureRecognizer
事件火灾方法中得到这两点.我怎样才能做到这一点?请指导我.
Swift Closure在引用self时会有一个强大的引用循环,如下例所示:
class Test {
var name = "Hello"
func doSomething() {
{() -> Void in
self.name = "otherName"
}()
}
}
Run Code Online (Sandbox Code Playgroud)
在前面的例子中,我创建了一个强大的引用循环,所以我必须修复它:
class Test {
var name = "Hello"
func doSomething() {
{[unowned self] () -> Void in
self.name = "otherName"
}()
}
}
Run Code Online (Sandbox Code Playgroud)
问题:如果我在封闭中引用自我,我是否必须总是使用unowned self
或者是否有必须使用的情况weak self
?
解压缩".ipa"文件时,输出为:包含应用程序的Payload目录.但是,有时输出是:Payload,SwiftSupport和Symbols目录.
另外,我注意到SwiftSupport包含.dylib
文件,我假设它们已经存在于应用程序中(右键单击 - >显示包内容 - >框架),因此:
我找不到任何有用的参考来描述我正在寻找的东西.
我正在尝试安排一周中特定日期的本地通知(例如周一,周三等),然后每周重复一次.这是用于设置通知的屏幕的外观:
用户可以选择通知时间和重复日期.
我调度单个非重复通知的方法如下所示:
static func scheduleNotification(reminder: Reminder) {
// Setup notification content.
let content = UNMutableNotificationContent()
//content.title = NSString.localizedUserNotificationString(forKey: "Reminder", arguments: nil)
content.body = NSString.localizedUserNotificationString(forKey: reminder.reminderMessage, arguments: nil)
content.sound = UNNotificationSound.default()
// Configure the triger for specified time.
//
let dateComponentes = reminder.dateComponents
// TODO: Configure repeating alarm
// For the testing purposes we will not repeat the reminder
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponentes, repeats: false)
// Create the request object.
let request = UNNotificationRequest(identifier: "\(reminder.reminderId)", content: content, trigger: trigger) …
Run Code Online (Sandbox Code Playgroud) 我在我的应用中请求用户位置.
locationManager.requestAlwaysAuthorization()
Run Code Online (Sandbox Code Playgroud)
这行代码应返回此警报消息:
但是,我希望用户仅在"不允许"和"始终允许"之间进行选择.如何删除"仅在使用应用程序时"选项?
知道这是我在info.plist中包含的内容,并且从info.plist中删除这3行中的任何行导致应用程序根本不显示此警报.
考虑以下两个排序的数组:
let arr1 = [1, 7, 17, 25, 38]
let arr2 = [2, 5, 17, 29, 31]
Run Code Online (Sandbox Code Playgroud)
简单地说,预期的结果应该是:
[1, 2, 5, 7, 17, 17, 25, 29, 31, 38]
Run Code Online (Sandbox Code Playgroud)
事实上,如果我们尝试对此问题进行简单的研究,我们会发现许多资源提供以下"典型"方法:
func mergedArrays(_ array1: [Int], _ array2: [Int]) -> [Int] {
var result = [Int]()
var i = 0
var j = 0
while i < array1.count && j < array2.count {
if array1[i] < array2[j] {
result.append(array1[i])
i += 1
} else {
result.append(array2[j])
j += 1
}
}
while i …
Run Code Online (Sandbox Code Playgroud) 考虑以下2D数组:
let array = [
[11, 2, 4],
[4, 5, 6],
[10, 8, -12]
]
Run Code Online (Sandbox Code Playgroud)
我想得到的是对角线的总和:
firstDiagnal
:11 + 5 +( - 12)= 4secondDiagnal
:4 + 5 + 10 = 19我可以使用标准for-in
循环来实现它:
var firstDiagnal = 0
var secondDiagnal = 0
for i in 0..<array.count {
firstDiagnal += array[i][i]
secondDiagnal += array[i][array[i].count - 1 - i]
}
print(firstDiagnal)
print(secondDiagnal)
Run Code Online (Sandbox Code Playgroud)
但是,如果我们尝试使用高阶函数会是什么呢?如map
和reduce
?
目前我正在使用这个:
var matchedUsersFromRealm = MatchedUser.allObjects()
var matchedUsersInRealm = RLMArray(objectClassName: MatchedUser.className())
matchedUsersInRealm.removeAllObjects()
matchedUsersInRealm.addObjects(matchedUsersFromRealm)
Run Code Online (Sandbox Code Playgroud)
但它看起来很麻烦,而不仅仅是它应该(或做到了?).也许有更好的方法?
PS,我正在研究混合项目,不知怎的,我只能使用Objective-C版本并将其桥接到我的快速项目中.所以Realm().objects()不可用,即使它返回的结果不是数组.
我是iOS开发的新手,想知道我是否可以修改CNContactPickerViewController
tableViewCell
已经使用我的应用程序的联系人以不同的方式显示.
并向未使用我的应用的联系人添加邀请按钮.
是否使用CNContactPickerViewController
了正确的方法?
谢谢!