【发布时间】:2016-08-17 19:27:09
【问题描述】:
我已经设置了 Parse.com 后端。在我的 iOS 应用程序中,我与此后端建立了连接,并且能够检索存储的对象。
我希望将每个特定对象存储在一个数组中。 假设我的 Key:value 所在的对象,例如:Category = Coffeebars
目前我已经编写了以下代码:
let queryToGetBuildings = PFQuery(className: "Building")
queryToGetBuildings.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
if error == nil {
for object in objects!{
print("this is an object")
print(object)
}
} else {
print("something went wrong")
}
分别返回我的每个对象:
"this is an object"
<Building: 0x7f, objectId: yh, localId: (null)> {
BottomText = "Opened from";
BottomTextExtra = "05:00 until 22:00";
Category = Coffeebars;
MiddleText = "Suggestion:";
MiddleTextExtra = "Apple and cinnamon";
TimeToDestination = 5;
TopText = Starbucks;
}
"this is an object"
<Building: 0xr, objectId: Xj, localId: (null)> {
BottomText = "Fee per person (not for babies):";
BottomTextExtra = "0.20";
Category = Toilets;
MiddleText = "Men - Women - Babies";
MiddleTextExtra = " ";
TimeToDestination = 5;
TopText = "Bathroom 2 terminal A";
}
"this is an object"
<Building: 0pr, objectId: 2q, localId: (null)> {
BottomText = "Fee per person (not for babies):";
BottomTextExtra = "0.20";
Category = Toilets;
MiddleText = "Men - Women";
MiddleTextExtra = " ";
TimeToDestination = 8;
TopText = "Bathroom 3 terminal A";
}
我现在的主要问题是如何打印出(并添加到特定数组中)具有 Key:Value = Category:Toilets 的对象的所有信息?
提前致谢
【问题讨论】:
-
你知道 Parse.com 将被关闭吗?
标签: arrays json swift parse-platform