【发布时间】:2015-09-22 03:33:48
【问题描述】:
在存储 Parse.com 上某个位置的营业时间方面需要一些基础设施方面的帮助,我已经尝试将它作为一个名为 BusinessHours 的单独类,其中每一行都有一个指向 Location 类的指针。对于 1 个位置,一周中的每一天至少有 7 行,对象数达到 +10.000
我这样做是为了确定该位置现在是否开放
for hour in hours {
if hour.isClosedAllDay {
isOpen = "closed".localized
}else{
let now = NSDate()
if now.hasDayOffset(hour.weekday, closeWeekDay: hour.nextWeekday) {
if hour.open != nil && hour.close != nil {
let open = now.hourDateFromString(hour.open!, offset: now.dayOpenOffset(hour.weekday, closeWeekDay: hour.nextWeekday))
let close = now.hourDateFromString(hour.close!, offset: now.dayCloseOffset(hour.weekday, closeWeekDay: hour.nextWeekday))
if now.isBetween(open, close: close) {
isOpen = "open".localized
timeOfBusiness = hour.time!
break
}
}
}
}
}
有没有比仅在营业时间拥有数千行更好的方法?我一直在考虑向位置类添加一个对象字段,但不知道这是否是正确的方法。
【问题讨论】:
标签: parse-platform