Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios PFObject类型的值在更新到Xcode 7后没有成员_Ios_Swift_Parse Platform_Swift2_Xcode7 - Fatal编程技术网

Ios PFObject类型的值在更新到Xcode 7后没有成员

Ios PFObject类型的值在更新到Xcode 7后没有成员,ios,swift,parse-platform,swift2,xcode7,Ios,Swift,Parse Platform,Swift2,Xcode7,在我将Xcode更新到7.0(和Swift 2.0)之后,我的应用程序不再接受我的一条解析语句。我有一个标准的解析查询。在该查询中,我有以下代码块: for user in users! { if !contains(accepted, user.username) && !contains(rejected, user.username){ self.use

在我将Xcode更新到7.0(和Swift 2.0)之后,我的应用程序不再接受我的一条解析语句。我有一个标准的解析查询。在该查询中,我有以下代码块:

for user in users! {
                            if !contains(accepted, user.username) && !contains(rejected, user.username){

                                self.usernames.append(user.username)
                                self.users.append(user as! PFUser)

                                if let data = user["image"] as? NSData {
                                    self.userImages.append(data)
                                }
                            }
我在上面代码中的
user.username
上遇到以下错误:

类型为“PFObject”的值没有成员“username”

我尝试删除/读取解析SDK,但没有成功。我甚至编辑了PFObject.h头文件(我在另一篇SO文章中找到了一个解决方案),但这也不起作用。有什么想法吗?解析SDK实现是否随Xcode 7而改变?我错过什么了吗

谢谢

编辑:完整代码的要点:

尝试以下操作:

if let users = users as? [PFUser] {
  for user in users {
    ...
  }
}
if !accepted.contains(user.username) && !rejected.contains(user.username)
更新:

如下所示:

if let users = users as? [PFUser] {
  for user in users {
    ...
  }
}
if !accepted.contains(user.username) && !rejected.contains(user.username)

似乎您的
users
PFObject
s的集合,而不是
PFUser
s感谢您的回复!我将集合初始化为PFUser。我怎样才能解决这个问题?不知道为什么它会将此视为PFObject。请看这里的全部要点:我不是Swift方面的专家,但看看我下面的答案是否有用。我认为这可能有效,但不确定。我在“如果”一行发现了一个新错误!包含(已接受,user.username!)&&!包含(已拒绝,user.username!)
。我在unavailable中得到错误
“contains”:调用序列“”上的“contains()”方法。知道这意味着什么吗?在查看此答案后,尝试将其更改为
user.contains(已接受,user.username)
,但仍然没有运气,表示PFUser没有成员“contains”
无法使用类型为([String],String)
的参数列表调用“contains”。我会接受这个答案,因为我认为你解决了最初的问题。现在我发现了越来越多的过时代码的问题,因为Xcode 7看起来像是在向
contains
函数传递两个参数。请参阅更新我的答案。