Restkit addFetchRequestBlock 崩溃

Restkit addFetchRequestBlock crashes

所以我得到了以下代码:

RKObjectManager.sharedManager().addFetchRequestBlock({
  url in

  // let pathMatcher = RKPathMatcher(path: "/v1/groups/")
  // var dict = NSDictionary?()
  // let match = pathMatcher.matchesPath(url.relativePath, tokenizeQueryStrings: false, parsedArguments: &dict)

  // if match {
  if let path = url.relativePath where path == "/v1/groups" {
    let fetchRequest = NSFetchRequest(entityName: String(self))
    fetchRequest.predicate = NSPredicate(format: "ANY member == %@", activeUser)
    return fetchRequest
  }

  return nil
})

它有效,但如您所见,它没有使用 RKPathMatcher。

如果我在取消注释的代码中添加注释,我得到:

*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 
'*** -[NSRegularExpression enumerateMatchesInString:options:range:usingBlock:]: nil argument'

没试过,dict部分应该是:

var dict: NSDictionary?

虽然看起来你没有使用它,所以你可以将它设置为 nil。