使用Xcode的beta 3,以下代码不再起作用:
func keyboardWasShown (notification: NSNotification)
{
var info = notification.userInfo
keyboardSize = info.objectForKey(UIKeyboardFrameBeginUserInfoKey).CGRectValue().size
}
Run Code Online (Sandbox Code Playgroud)
在指示:
keyboardSize = info.objectForKey(UIKeyboardFrameBeginUserInfoKey).CGRectValue().size
Run Code Online (Sandbox Code Playgroud)
XCode返回错误[NSObject:AnyObject]没有名为objectForKey的成员.
所以我改变了这样的代码:
func keyboardWasShown (notification: NSNotification)
{
var info = notification.userInfo
keyboardSize = info[UIKeyboardFrameBeginUserInfoKey].CGRectValue().size
}
Run Code Online (Sandbox Code Playgroud)
但是XCode返回错误"String不是子类型f DictionaryIndex"
我正在Swift的Xcode 6 Beta 6中构建一个应用程序,我不断收到此错误:
[NSObject : AnyObject]?' does not have a member named 'subscript'
Run Code Online (Sandbox Code Playgroud)
我不知道如何解决这个问题.我试过看[NSObject:AnyObject]?在Xcode 6 beta 6中没有名为'subscript'的成员,但我仍然不明白如何解决这个问题.如果有人可以向我解释,那将是非常好的.如果你想看我的代码,这里是:
import UIKit
class TimelineTableViewController: UITableViewController {
override func viewDidAppear(animated: Bool) {
if ((PFUser.currentUser()) != nil) {
//Create an UIAlertController if there isn't an user
var loginAlert:UIAlertController = UIAlertController(title: "Sign Up/ Log In", message: "Please sign up or log in", preferredStyle: UIAlertControllerStyle.Alert)
//Add a textView in the Log In Alert for the username
loginAlert.addTextFieldWithConfigurationHandler({
textfield in
textfield.placeholder = "Your Username"
}) …Run Code Online (Sandbox Code Playgroud) 我有类似这个问题的问题,但那里的答案没有帮助我.
我有这些代码行:
var id = item["id"] as? String ?? ""
var name = item["name"] as? String ?? ""
var pic = item["pic"] as? String ?? ""
Run Code Online (Sandbox Code Playgroud)
对我来说,这些代码行几乎相同.对于Xcode,这是另一回事.
第一行很好.后两行产生此错误:
'(key: AnyObject, value: AnyObject)' does not have a member named 'subscript'
Run Code Online (Sandbox Code Playgroud)
这里有一些更适合你的背景:
class func getFromJson(json:NSDictionary) -> [Collection] {
var collections = [Collection]()
if json.count > 0 {
for item in json {
var id = item["id"] as? String ?? ""
var name = item["name"] as? String ?? ""
var pic …Run Code Online (Sandbox Code Playgroud) 我在xcode上使用swift和解析,我一直收到这个错误:
[Error]: invalid login parameters (Code: 101, Version: 1.7.2)
Run Code Online (Sandbox Code Playgroud)
每当我尝试登录用户时,我知道用户是在解析后端创建的,并且其信息是正确的.我该怎么做才能阻止这种情况发生并让用户在没有应用程序发回无效登录参数的情况下登录?
这是我的LogInViewController:
import Foundation
import Parse
import UIKit
import Bolts
class LoginViewController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var loginStatusLabel: UILabel!
@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var passwordTextField: UITextField!
@IBOutlet weak var loginButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
emailTextField.delegate = self
passwordTextField.delegate = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that …Run Code Online (Sandbox Code Playgroud)