Restkit addFetchRequestBlock崩溃

时间:2016-08-22 15:55:47

标签: ios swift restkit

所以我得到了以下代码:

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'

1 个答案:

答案 0 :(得分:1)

我没试过,但dict部分应该是:

var dict: NSDictionary?

虽然它看起来不像你正在使用它所以你可以把它设置为零。