『iOS學習筆記』 類型轉換失敗(use of undeclared identifier)
下面這句話為何拋錯:use of undeclared identifier,
-(void)request { NSObject *otherBizData = [iLoginViewController callAddBiz]; NSObject *otherRequestData = [iLoginViewController callAdd]; if([otherRequestData isKindOfClass:[NSArray class]] && [otherBizData isKindOfClass:[NSArray class]] && [(NSArray *)otherRequestData count] == [(NSArray *)otherBizData count] ) { NSArray *otherRequestDataArray = (NSArray *)otherRequestData; NSArray *otherBizDataArray = (NSArray *)otherBizData; } }
肉眼分析疑似問題語句是:[(NSArray *)otherRequestData count] == [(NSArray *)otherBizData count]
試驗如下,問題解決:
疑似分析:這句話已經將NSObject 轉了一次NSArray,故第二次再轉換時找不到NSObject變量了,於是拋錯:使用未定義唯一標識的對象。
問題:到底是轉了一次后otherRequestData沒有了?還是轉兩次導致里面有2個otherRequestData無法識別?
歡迎高手拍磚~