使用未解析的标识符'PFUser' - Swift / Xcode / Parse

时间:2022-12-01 06:31:11

I am trying to query the users in my Parse DB into my Table View Controller in my app in Xcode.

我试图在我的Podes数据库中查询我的应用程序中的表视图控制器。

I am a beginner, but I have posted my code snippet from my added .swift file to my project. I am trying to query the user in the .swift file but it is not recognizing 'PFUser' from my View Controller.

我是初学者,但是我已将我添加的.swift文件中的代码片段发布到我的项目中。我试图在.swift文件中查询用户,但它没有从我的View Controller识别'PFUser'。

Do I need to declare the PFUser as something in my .swift file before first calling it in my ViewDidLoad method?

在我的ViewDidLoad方法中首次调用它之前,是否需要将PFUser声明为我的.swift文件中的内容?

Any ideas?

Code snippet: 使用未解析的标识符'PFUser' -  Swift / Xcode / Parse

3 个解决方案

#1


5  

You need to import the Parse-Framework in your project. Check this quickstart-guide how to do it.

您需要在项目中导入Parse-Framework。查看此快速入门指南如何操作。

If you've done it already, you need to import Parse in your File like that:

如果你已经完成了,你需要在文件中导入Parse,如下所示:

import UIKit
import Parse

Like you/Xcode has already done that with the UIKit.

像你/ Xcode已经用UIKit做到了。

#2


2  

  1. First put Parse SDK into the folder into your project navigator area of Xcode.

    首先将Parse SDK放入Xcode的项目导航区域的文件夹中。

  2. You will get a Dialogue, You will need to check the box that says copy items if needed and then click Finish.

    您将获得一个对话框,如果需要,您需要选中复制项目框,然后单击完成。

  3. The next thing we need to do to connect our Swift app to parse.com is create a bridging header. To do this you need to create a new File (File -> New -> File) of type Objective-C File. Call this whatever you like. Here I have just called it testDataCustom. You will see another Dialogue that looks like having this Line at the top "Would you like to configure Objective C bridging Header?" Click on Yes.

    接下来我们需要做的是将Swift应用程序连接到parse.com,这就是创建一个桥接头。为此,您需要创建一个Objective-C File类型的新文件(File - > New - > File)。不管你喜欢什么,都可以打我在这里称它为testDataCustom。您将看到另一个对话,看起来像这条线在顶部“你想配置Objective C桥接标题吗?”单击是。

  4. Now it will add some new files to your project. Click on the File: testData-Bridging-Header.h. You should see this:

    现在它将为您的项目添加一些新文件。单击File:testData-Bridging-Header.h。你应该看到这个:

     // Use this file to import your target's public headers that you would like to expose to Swift.
    

5.Underneath this comment code we need to add an #import so that our project knows to use the Parse iOS SDK. To do this we simply add a line into this file, like so:

5.在这个注释代码下面,我们需要添加一个#import,以便我们的项目知道使用Parse iOS SDK。为此,我们只需在此文件中添加一行,如下所示:

#import <Parse/Parse.h>

Now you can successfully use Parse methods and properties. Referred from this Link

现在您可以成功使用Parse方法和属性。从这个链接引用

#3


0  

You have to import the proper Parse file. :)

您必须导入正确的Parse文件。 :)

I don't know Swift but I assume that of you type

我不知道斯威夫特,但我假设你打字

 Import Parse.h 

It will autocomplete for you.

它会自动完成。

From what I know in objective-c, you might need to import

根据我在objective-c中的了解,您可能需要导入

Import <Parse\Parse.h>

#1


5  

You need to import the Parse-Framework in your project. Check this quickstart-guide how to do it.

您需要在项目中导入Parse-Framework。查看此快速入门指南如何操作。

If you've done it already, you need to import Parse in your File like that:

如果你已经完成了,你需要在文件中导入Parse,如下所示:

import UIKit
import Parse

Like you/Xcode has already done that with the UIKit.

像你/ Xcode已经用UIKit做到了。

#2


2  

  1. First put Parse SDK into the folder into your project navigator area of Xcode.

    首先将Parse SDK放入Xcode的项目导航区域的文件夹中。

  2. You will get a Dialogue, You will need to check the box that says copy items if needed and then click Finish.

    您将获得一个对话框,如果需要,您需要选中复制项目框,然后单击完成。

  3. The next thing we need to do to connect our Swift app to parse.com is create a bridging header. To do this you need to create a new File (File -> New -> File) of type Objective-C File. Call this whatever you like. Here I have just called it testDataCustom. You will see another Dialogue that looks like having this Line at the top "Would you like to configure Objective C bridging Header?" Click on Yes.

    接下来我们需要做的是将Swift应用程序连接到parse.com,这就是创建一个桥接头。为此,您需要创建一个Objective-C File类型的新文件(File - > New - > File)。不管你喜欢什么,都可以打我在这里称它为testDataCustom。您将看到另一个对话,看起来像这条线在顶部“你想配置Objective C桥接标题吗?”单击是。

  4. Now it will add some new files to your project. Click on the File: testData-Bridging-Header.h. You should see this:

    现在它将为您的项目添加一些新文件。单击File:testData-Bridging-Header.h。你应该看到这个:

     // Use this file to import your target's public headers that you would like to expose to Swift.
    

5.Underneath this comment code we need to add an #import so that our project knows to use the Parse iOS SDK. To do this we simply add a line into this file, like so:

5.在这个注释代码下面,我们需要添加一个#import,以便我们的项目知道使用Parse iOS SDK。为此,我们只需在此文件中添加一行,如下所示:

#import <Parse/Parse.h>

Now you can successfully use Parse methods and properties. Referred from this Link

现在您可以成功使用Parse方法和属性。从这个链接引用

#3


0  

You have to import the proper Parse file. :)

您必须导入正确的Parse文件。 :)

I don't know Swift but I assume that of you type

我不知道斯威夫特,但我假设你打字

 Import Parse.h 

It will autocomplete for you.

它会自动完成。

From what I know in objective-c, you might need to import

根据我在objective-c中的了解,您可能需要导入

Import <Parse\Parse.h>