【发布时间】:2016-02-19 11:58:02
【问题描述】:
在我的ViewController 中,我有一个标签,显示在之前的ViewController 中选择的俱乐部名称。我现在需要从我的 parse.com 类创建一个查询,以检索与显示为标签的俱乐部名称匹配的对象的所有信息。我知道如何成功查询解析,但我发现很难找到一种方法将查询与标签字符串相匹配,因为标签字符串可能会有所不同,具体取决于在前一个视图中选择的俱乐部。
代码:
import UIKit
import Parse
class MenuController: UIViewController {
@IBOutlet weak var clubLabel: UILabel!
var clubName = String()
override func viewDidLoad() {
super.viewDidLoad()
clubLabel.text = clubName
}
}
Previous View 已查询解析以使用俱乐部注释填充地图,如下所示:
let annotationQuery = PFQuery(className: "Clubs")
annotationQuery.findObjectsInBackgroundWithBlock{
(clubs, error) -> Void in
if error == nil {
// The find succeeded.
print("Successful query for annotations")
// Do something with the found objects
let myClubs = clubs! as [PFObject]
for club in myClubs {
//data for annotation
let annotation = MKPointAnnotation()
let place = club["location"] as? PFGeoPoint
let clubName = club["clubName"] as? String
let stadiumName = club["stadium"] as? String
annotation.title = clubName
annotation.subtitle = stadiumName
annotation.coordinate = CLLocationCoordinate2DMake(place!.latitude,place!.longitude)
//add annotations
self.mapView.addAnnotation(annotation)
【问题讨论】:
-
但是您已经拥有了用于填充标签的对象,那么您对它做了什么?使用现有对象...
-
更多信息是什么?您是如何获得这些球杆的?为什么这些对象不包含您需要的数据(或与数据的关系)?
-
上一个视图中的“俱乐部标签数组”是如何填充的?如果你从 Parse 得到它,你为什么不保留这个对象呢?
标签: ios database swift parse-platform