bawn/LCNetwork

运行了几次就崩了

xujiajia opened this issue · 5 comments

2015-12-25 12:26:32.811 LCNetworkDemo[2737:89194] -[**NSCFString objectForKeyedSubscript:]: unrecognized selector sent to instance 0x7fc338706b80
2015-12-25 12:26:32.815 LCNetworkDemo[2737:89194] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKeyedSubscript:]: unrecognized selector sent to instance 0x7fc338706b80'
* First throw call stack:
(
0 CoreFoundation 0x0000000108d91e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010880adeb objc_exception_throw + 48
2 CoreFoundation 0x0000000108d9a48d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000108ce790a __forwarding
+ 970
4 CoreFoundation 0x0000000108ce74b8 _CF_forwarding_prep_0 + 120
5 LCNetworkDemo 0x000000010682e8f8 -[ViewController viewDidLoad] + 264
6 UIKit 0x000000010747df98 -[UIViewController loadViewIfRequired] + 1198
7 UIKit 0x000000010747e2e7 -[UIViewController view] + 27
8 UIKit 0x0000000107354ab0 -[UIWindow addRootViewControllerViewIfPossible] + 61
9 UIKit 0x0000000107355199 -[UIWindow _setHidden:forced:] + 282
10 UIKit 0x0000000107366c2e -[UIWindow makeKeyAndVisible] + 42
11 UIKit 0x00000001072df663 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
12 UIKit 0x00000001072e5cc6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1760
13 UIKit 0x00000001072e2e7b -[UIApplication workspaceDidEndTransaction:] + 188
14 FrontBoardServices 0x000000010b06a754 -[FBSSerialQueue _performNext] + 192
15 FrontBoardServices 0x000000010b06aac2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
16 CoreFoundation 0x0000000108cbda31 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
17 CoreFoundation 0x0000000108cb395c __CFRunLoopDoSources0 + 556
18 CoreFoundation 0x0000000108cb2e13 __CFRunLoopRun + 867
19 CoreFoundation 0x0000000108cb2828 CFRunLoopRunSpecific + 488
20 UIKit 0x00000001072e27cd -[UIApplication _run] + 402
21 UIKit 0x00000001072e7610 UIApplicationMain + 171
22 LCNetworkDemo 0x000000010683325f main + 111
23 libdyld.dylib 0x000000010981792d start + 1
24 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

bawn commented

@xujiajia 已修复,由于 response 被再次加工了

- (id)responseProcess:(id)responseObject{
    return responseObject[@"Weather"];
}

就会缓存 responseObject[@"Weather"] 这个数据

所以在取 cache 的时候

 if (api1.cacheJson) {
        self.city1.text = api1.cacheJson;
    }

直接取就可以了

@bawn 收到 3Q 你这个请求框架简化了YTK的 非常nice 计划用你这个 加上mantle 改吧改吧用 哈哈

bawn commented

@xujiajia 谢谢,一般我都是这么用

- (id)responseProcess:(id)responseObject{
    return [MTLJSONAdapter modelsOfClass:[HQChannelListItem class] fromJSONArray:responseObject error:nil];
}
[self.homeChannelListApi startWithBlockSuccess:^(id request) {
            self.dataSourceArray = [request responseJSONObject];
            [self.tableView reloadData];
        } failure:NULL];

@bawn 3Q 有什么问题再问你

@bawn 发现没有ChainRequest,计划用promisekit代替。