我想用RestKit同步加載對象,並在後臺線程上使用[anObjectLoader sendSynchronously]
。然後在RKObjectLoader
didFinishLoad:應用程序當前停在第一條線:從RKRequest
類NSAssert([NSThread isMainThread], @"RKObjectLoaderDelegate callbacks must occur on the main thread");
望着documentation,該sendSynchronously
法說,該請求將被同步請求和水合響應對象將返回。
這是我的代碼的快照:RestKit sendSynchronously方法的最佳做法
RKObjectLoader *anObjectLoader = [self.objectManager loaderWithResourcePath:resourcePath];
NSLog(@"Response: %@", [anObjectLoader sendSynchronously]);
在控制檯上:
*** Assertion failure in -[RKManagedObjectLoader didFinishLoad:], ...RestKit/Code/ObjectMapping/RKObjectLoader.m:423
是否確定使用RestKit與同步調用?
有更好的方法發送同步請求嗎?
我錯過了什麼嗎?
謝謝保羅。在閱讀網絡上的其他問題和答案後[1](http://stackoverflow.com/questions/7325181/making-synchronous-calls-with-restkit),[2](https://groups.google.com/forum /?fromgroups#!searchin/restkit/synchronous/restkit/ozbyf9hbbHY/4FUGPiZKIXwJ),[3](https://groups.google.com/forum/?fromgroups#!searchin/restkit/synchronous/restkit/jUHOJOF4_nk/ FULzlmEy14gJ)等等,我最終同意你的答案。 – georgepiva 2012-08-07 16:28:11