- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 NSTableView,它使用 ArrayController 从 CoreData 中提取数据。在我的表单中,我也有搜索字段。
搜索表单在以下情况下工作正常:
我选择搜索字段,并在谓词下的绑定(bind)检查器中将搜索字段绑定(bind)到用于获取 nstableview 中的数据的数组 Controller 。
在谓词格式字段中我添加
customerName contains[cd] $value 或 customerWebsite contains[cd] $value
现在,无论是搜索 customerName (STRING) 还是 customerWebsite (STRING),我都能得到很好的结果。
但是,如果我用包含 DATE 的字段更改字段,我的搜索将不起作用。例如,以下注释不起作用:
contractExpiresOn contains[cd] $value
contractExpiresOn == $value
contractExpiresOn = $value
contractExpiresOn >= $value
contractExpiresOn > $value
contractExpiresOn %LIKE $value
//contractExpiresOn is DATE
当我使用上述谓词格式进行搜索时,应用程序不会崩溃,但不会返回任何结果,即使例如我有以 0 开头的日期,只要我在搜索字段中输入 0,NSTableView 就是空的.
任何人都可以告诉我如何通过界面生成器使我的搜索与日期一起使用,或者如果不可能,我该如何以编程方式执行此操作。
最佳答案
您无法将日期与字符串进行比较,您必须进行一些编程。在 NSDate 上创建一个类别并添加将日期转换为字符串的方法。例如:
@implementation NSDate(Search)
static NSDateFormatter *searchDateFormatter = nil;
- (NSString *)searchString {
if (!searchDateFormatter) {
searchDateFormatter = [[NSDateFormatter alloc] init];
searchDateFormatter.dateStyle = NSDateFormatterShortStyle;
searchDateFormatter.timeStyle = NSDateFormatterNoStyle;
}
return [searchDateFormatter stringFromDate:self];
}
@end
谓词格式为birthday.searchString contains $value
。
关于objective-c - 使用 InterfaceBuilder 在 NSTableView 和 CoreData 中按 DATE 搜索记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36075515/
我正在开发一个简单的 iPhone 应用程序。 我有 1 个 UINavigationController 和 2 个 UIViewController 子类。 我有一个 MainWindow.xib
我对 Cocoa/Xcode 比较陌生,不确定我是否以最“正确”的方式构建我的应用程序。我有许多在应用程序运行时处于事件状态的对象。我应该手动创建这些对象还是使用 Interface Builder?
我想以编程方式设置 uilabel 的自动调整大小设置。 我想要与我设置的界面生成器设置中完全相同的设置,请参见此处: http://imageshack.us/photo/my-images/545
我想以编程方式设置 uilabel 的自动调整大小设置。 我想要与我设置的界面生成器设置中完全相同的设置,请参见此处: http://imageshack.us/photo/my-images/545
这个问题在这里已经有了答案: UIColor vs IB color (color profile issue) (1 个回答) 关闭 5 年前。 我正在通过 UIView 扩展为 UITextFi
我想使用 CALayer 向 UI(图像) View 添加投影。以下代码通常可以正常工作 previewImage.layer.shadowColor = [[UIColor blackColor]
我想使用 IB 在单独的 .xib 中创建自定义标题部分 View 但是在 IB 中我找不到组件 UITableViewHeaderFooterView(类似于 UITableViewCell)并为其
我正在为 iPhone 应用程序设置 UIGestureRecognizer。我在 InterfaceBuilder 中通过将长按手势识别器从对象库拖动到必须接受手势的 View 来完成此操作。 以这
我正在开发一个 iPhone 应用程序,它是另一个启动器的“模块”(它不会从 iPhone 主屏幕启动)。要将此模块添加到启动器,我必须将 xcode 文件放入父 xcode 项目(创建子项目)中。子
如果我在 Interface Builder 中将 NSScrollView 的自定义类设置为 IKImageBrowserView,我在 Attributes Inspector Pane 中看不到
我使用 GIT,在 pull/推送项目存储库后,我去运行应用程序来测试我推送的工作版本。然而,运行应用程序后,我在编译时立即遇到了这个错误: “无法打开文档“Setstory.storyboard”。
我在 MainStoryboard 上添加了多个标签并给它们相同的颜色。但我想在一个地方设置颜色代码并将其应用于所有标签。 我知道一种方法连接 View Controller 中的所有标签并应用任何颜
我正在为我的 Swift 应用程序创建一个设置页面,并且(下面是关于 SO 的示例)我已经子类化了一个 UITableViewCell 并且在 init() 处理程序中我已将 accessoryVie
我想知道它是什么意思,以及为什么在代码中使用它: com.apple.InterfaceBuilder.IBCocoaTouchPlugin 我有一个源代码,其中: 已被使用。我们为什么要使用它?
在 IB 中,当我转到属性检查器并单击“背景”下拉菜单 -> 其他时,我得到一个带有多个选项卡(滚轮、 slider 、apllets)的颜色托盘,但没有地方可以设置精确的此类例如#ff5911。 有
通过大量的在线文档和开发中心的各种代码示例,我感到很困惑。 Apple 建议在创建 View 时始终使用 IB,然而,在许多代码示例中, View 完全在代码中创建(在 viewController
很多人都问过类似的问题,但回答要么不够模糊,要么不符合我需要的方向,所以我会尝试尽可能具体地问这个问题。这个问题的上下文是针对使用 XCode 4 的 iOS 开发。 我有一个应用程序,我多次使用同一
NSLayoutConstraint(在 iOS 8.0 中)有一个名为 active 的 BOOL 属性,可以轻松禁用/即时启用所述布局约束。 要为 View Controller 创建第二个布局集
我一直在想,有没有什么好的方法可以在 Interface Builder 中制作带有多行 titleLabel 的 UIButtons?我没有发现任何东西,并在每个按钮顶部放置一个单独的 UILabe
我想将PageController与下面的三个ViewController连接起来,以设置下层SplitView的内容。关于如何做到这一点有什么想法吗? 最佳答案 不幸的是,没有标准的方法来嵌入它们。
我是一名优秀的程序员,十分优秀!