openURL已在Swift3中弃用.任何人都可以提供一些示例,说明openURL:options:completionHandler:在尝试打开网址时替换是如何工作的吗?
我正在关注Mac OS X的Quickstart以安装云SDK.完全按照步骤,
1)python -V返回"Python 2.7.10"
2)./install.sh在google-cloud-sdk中使用64位版本的SDK 下载并解压缩...
Welcome to the Google Cloud SDK!
To help improve the quality of this product, we collect anonymized usage data
and anonymized stacktraces when crashes are encountered; additional information
is available at <https://cloud.google.com/sdk/usage-statistics>. You may choose
to opt out of this collection now (by choosing 'N' at the below prompt), or at
any time in the future by running the following command:
gcloud config set …Run Code Online (Sandbox Code Playgroud) 从今天的Swift3日期开始,18年前的正确方法是什么?
在Swift2中,我有
let startingDate = NSDate(timeIntervalSinceNow: -600000000)
Run Code Online (Sandbox Code Playgroud) 在更新到推荐的pod设置后,我在Xcode中收到警告.警告是
Possible misuse of comma operator here
Run Code Online (Sandbox Code Playgroud)
建议修复
Cast expression to void to silence warning
Run Code Online (Sandbox Code Playgroud)
警告发生在leveldb-library/db/c.cc的开始和限制键:
void leveldb_compact_range(
leveldb_t* db,
const char* start_key, size_t start_key_len,
const char* limit_key, size_t limit_key_len) {
Slice a, b;
db->rep->CompactRange(
// Pass NULL Slice if corresponding "const char*" is NULL
(start_key ? (a = Slice(start_key, start_key_len), &a) : NULL),
(limit_key ? (b = Slice(limit_key, limit_key_len), &b) : NULL));
}
Run Code Online (Sandbox Code Playgroud)
有没有其他人有同样的或知道是什么导致它?我正在运行Cocoapods 1.2.0.
管理员是否有办法从控制台内部查看和更改电子邮件验证的状态?到目前为止我发现的所有内容都仅基于客户端从后端推送验证电子邮件并检查其状态。对于管理员来说,了解这一点也很有用。
\n升级到最新的Xcode后,我遇到了一系列错误。
MyApp/Pods/Protobuf/objectivec/google/protobuf/Any.pbobjc.m:17:10: Non-portable path to file '<protobuf/Any.pbobjc.h>'; specified path differs in case from file name on disk
Run Code Online (Sandbox Code Playgroud)
当我查看代码时,我发现路径的确是大写的。
#import <Protobuf/Any.pbobjc.h>
Run Code Online (Sandbox Code Playgroud)
有什么建议如何解决这个问题?
我的pod文件看起来像这样:
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
target 'MyApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for MyApp
pod 'Firebase/Core'
pod 'Firebase/Storage'
pod 'Firebase/Database'
pod 'Firebase/Firestore'
pod 'Firebase/Auth'
pod 'Firebase/AdMob'
# Pods for PodTest
pod …Run Code Online (Sandbox Code Playgroud) 升级到Swift3后,升级帮助程序发生了变化
private var myArray = [(String, NSDate, Float)]() //Swift 2.2
Run Code Online (Sandbox Code Playgroud)
至
fileprivate var myArray = [(String, Foundation.Date, Float)] //Swift 3
Run Code Online (Sandbox Code Playgroud)
新代码出错Expected member name or constructor call after type name.
有没有人理解错误的原因或正确的语法方法应该是什么?编译器提出的解决方案是Add arguments after the type to construct a value of the type或Use .self to reference the type object.这些不能解决问题.
我打电话touchesBegan()的时候
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
print("TOUCH_BEGAN")
}
Run Code Online (Sandbox Code Playgroud)
我得到了打印声明.我注意到,如果我不移动接触点,
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
print("TOUCH_ENDED")
}
Run Code Online (Sandbox Code Playgroud)
没有被召唤,但是当我移动接触点时.呼叫需要一些最小的移动touchesEnded()吗?如果是这样,有没有办法覆盖这一点,以确保touchesEnded()始终被称为?
完整的代码太长了,无法添加,但下面多一点:
import SpriteKit
import UIKit
import Foundation
class GameScene: SKScene, SKPhysicsContactDelegate {
// MARK: Properties
var touchStart: CGPoint?
let minSwipeDistance:CGFloat = 22
var distance: CGFloat = 0
override func didMoveToView(view: SKView) {
super.didMoveToView(view)
//...
// MARK: INCLUDE SWIPE GESTURES
let swipeRight: UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: Selector("swipedRight:"))
swipeRight.direction = .Right
swipeRight.cancelsTouchesInView …Run Code Online (Sandbox Code Playgroud) 我一直在寻找Firebase文档,并找到了重新验证用户身份的方法,如下所示。
let user = Auth.auth().currentUser
var credential: AuthCredential
// Prompt the user to re-provide their sign-in credentials
user?.reauthenticate(with: credential) { error in
if let error = error {
// An error happened.
} else {
// User re-authenticated.
}
}
Run Code Online (Sandbox Code Playgroud)
我从编译器收到如下错误和警告:
错误:
初始化之前使用的变量“凭据”
警告:
不建议使用“ reauthenticate(with:completion :)”:对于Objective-C,请使用reauthenticateAndRetrieveDataWithCredential:completion :;对于Swift,请使用reauthenticateAndRetrieveData(WithCredential:completion :)。
有没有人举一个更新方法的例子?
是否有方法为寻找其他信息的用户添加网址?我的警报看起来像这样
let alert = UIAlertController(title: "Alert details", message: "For more detailed information, click the link below", preferredStyle: UIAlertControllerStyle.Alert)
// add url here
let okayAction = UIAlertAction(title: "Ok", style: .Default) { (action) in
print(action)
}
alert.addAction(okayAction)
Run Code Online (Sandbox Code Playgroud)
我们的想法是将它们重定向到网页并关闭应用程序中的UIAlertController
我正在运行一段代码,该代码nil在使用其他语言设置的iPhone上运行时会返回。代码中的示例如下所示:
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "MMM d, yyyy, h:mm a"
let thisDate = "Mar 4, 2017, 7:50 PM"
let foundationDate = dateFormatter.string(from: Foundation.Date())
print("As String - thisDate: \(thisDate), foundationDate: \(foundationDate)")
print("As Date - thisDate: \(dateFormatter.date(from: thisDate)), foundationDate: \(dateFormatter.date(from: foundationDate))")
Run Code Online (Sandbox Code Playgroud)
如果运行此命令,则会得到:
As String - thisDate: Mar 4, 2017, 7:50 PM, foundationDate: okt. 22, 2017, 7:57 PM
As Date - thisDate: nil, foundationDate: Optional(2017-10-22 17:57:00 +0000)
Run Code Online (Sandbox Code Playgroud)
任何人都可以显示如何覆盖客户端设置,从而thisDate不会返回nil吗?
我有以下代码,它使用警报来收集用户的电子邮件地址。我想指定键盘类型,但无法弄清楚如何在警报中执行此操作。有谁能帮忙演示一下如何设置.keyboardType = UIKeyboardType.emailAddress吗?
var userInput: String = ""
let prompt = UIAlertController.init(title: nil, message: "Enter your email address", preferredStyle: UIAlertControllerStyle.alert)
let okAction = UIAlertAction.init(title: "OK", style: UIAlertActionStyle.default) { (action) in
userInput = prompt.textFields![0].text
if (userInput!.isEmpty) {
return
}
}
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (action) in
print(action)
}
prompt.addTextField(configurationHandler: nil)
prompt.addAction(okAction)
prompt.addAction(cancelAction)
self.view?.window?.rootViewController?.present(prompt, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)