这让我疯了.
在雨燕2.2,这使得它不可能下标String有Int.例如:
let myString = "Test string"
let index = 0
let firstCharacter = myString[index]
Run Code Online (Sandbox Code Playgroud)
这将导致编译错误,说
'subscript'不可用:不能使用Int下标String,请参阅文档注释以供讨论
我看到的一个解决方法是将整数转换为索引类型,但我无法弄清楚如何...
我到处寻找,甚至用一些永远不会消失的病毒警告信息打到一些可疑的网站,我无法弄清楚这一点.
我只是想Results<T>按日期过滤对象:
let messages = realm.objects(RMChatMessage).filter("timestamp > \(date)) AND (timestamp <= \(to))"))
Run Code Online (Sandbox Code Playgroud)
无论何时运行此行,它都会引发以下情况:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "timestamp > 1970-01-01 00:00:00 +0000"'
*** First throw call stack:
(
0 CoreFoundation 0x000000010fba8c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000011174ebb7 objc_exception_throw + 45
2 Foundation 0x000000010ffb66bd _qfqp2_performParsing + 8495
3 Foundation 0x000000010ffb4526 +[NSPredicate predicateWithFormat:arguments:] + 46
...
Run Code Online (Sandbox Code Playgroud)
我尝试使用NSDateFormatter格式yyyy-MM-dd hh:mm:ss,或者date.description,使用NSPredicate(format:...)而不是Result<T>.filter(...)等等,但没有任何效果.
这是Realm中的一些错误吗?