有没有办法停止所有RestKit处理?

时间:2012-09-26 15:21:29

标签: objective-c ios restkit

我在RestKit的错误回调中切换控制器时遇到问题。它会导致错误:

*** -[RKObjectLoader onDidFailWithError]: message sent to deallocated instance 0x1ddd9680

我正在使用以下代码切换方法- (void)objectLoader:(RKObjectLoader *)objectLoader didFailWithError:(NSError *)error

[[[[RKObjectManager sharedManager] client] requestQueue] cancelAllRequests];

scAppDelegate *appDelegate = (scAppDelegate *)[UIApplication sharedApplication].delegate;
WelcomeController *controller = [[WelcomeController alloc] init];
[controller createWelcome];
appDelegate.window.rootViewController = controller;
[appDelegate.window addSubview:[controller view]];
[appDelegate.window makeKeyAndVisible];

我的问题出在第一行,因为它不会取消所有RestKit处理。在日志中,我看到一些ObjectMapping操作,它们导致EXC_BAD_ACCESS (SIGSEGV)错误。我找到了一个解决方法 - 延迟后切换控制器(使用performSelector:withObject:afterDelay)。但我正在寻找更好的解决方案。

ObjectMapping操作是:

2012-09-26 14:50:09.408 dr[5004:907] W restkit.object_mapping:RKObjectMapper.m:87 Adding mapping error: Could not find an object mapping for keyPath: ''
2012-09-26 14:50:09.410 dr[5004:907] E restkit.network:RKObjectLoader.m:231 Encountered errors during mapping: Could not find an object mapping for keyPath: ''
2012-09-26 14:50:09.411 dr[5004:907] E restkit.network:RKObjectLoader.m:360 Encountered an error while attempting to map server side errors from payload: Could not find an object mapping for keyPath: ''
2012-09-26 14:50:09.419 dr[5004:907] I restkit.support:RKCache.m:189 Invalidating cache at path: /var/mobile/Applications/1B9919DC-0674-494D-9C26-F1FC1925E856/Library/Caches/RKClientRequestCache-dr.cloudapp.net/SessionStore
2012-09-26 14:50:09.422 dr[5004:907] I restkit.network.reachability:RKReachabilityObserver.m:123 Reachability observer initialized with IP address: 0.0.0.0.

我正在使用最新版本的RestKit。

2 个答案:

答案 0 :(得分:1)

来自RestKit 0.20.0:

[[[RKObjectManager sharedManager] operationQueue] cancelAllOperations];

答案 1 :(得分:0)

您是否有理由要求客户取消所有操作?通常你会要求RKObjectManager完成这项工作。

[[[[RKObjectManager sharedManager] requestQueue] cancelAllRequests];