现在的位置: 首页 > 综合 > 正文

『iOS小案例』 类型转换失败(use of undeclared identifier)

2013年05月02日 ⁄ 综合 ⁄ 共 707字 ⁄ 字号 评论关闭

『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无法识别?

 

欢迎高手拍砖~

抱歉!评论已关闭.