『iOS小案例』 類型轉換失敗(use of undeclared identifier)


『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無法識別?

 

歡迎高手拍磚~


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM