Objective c EXC_BAD_使用ARC上的委托访问NSXMLParser

Objective c EXC_BAD_使用ARC上的委托访问NSXMLParser,objective-c,xcode,delegates,automatic-ref-counting,Objective C,Xcode,Delegates,Automatic Ref Counting,我在解析器DidendElement中有这段代码 [self setImageThumbnailLink:[NSMutableString stringWithString:imageLink]]; if([_delegate respondsToSelector:@selector(receiveImageLink:withParser:withParameter:)]){ [_delegate receiveImageLink:[self imageThumb

我在解析器DidendElement中有这段代码

   [self setImageThumbnailLink:[NSMutableString stringWithString:imageLink]];
    if([_delegate respondsToSelector:@selector(receiveImageLink:withParser:withParameter:)]){

        [_delegate receiveImageLink:[self imageThumbnailLink] withParser:nil withParameter:parameterPassed];
    }        
    else{            
        [NSException raise:NSInternalInconsistencyException
                    format:@"Delegate doesn't respond to receiveItems:"];
    } 
当代码到达[_delegatereceiveimagelink:[self-imageThumbnailLink]with parser:nil with parameter:parameter passed]

EXC\u出现错误访问。我试着把每个参数设为nil,从而找出它的问题所在。当[self-imageThumbnailLink]传递给代理时,会发生EXC_错误访问。 我怎样才能解决这个问题? 我使用[nonatomic,strong]作为imageThumbnailLink。它是NSMutableString。 如果我使用此代码(不使用变量):它工作正常

 [_delegate receiveImageLink:@"http://www.....flower.jpg" withParser:nil withParameter:parameterPassed];
多谢各位

控制台中的错误消息: 只有 当前语言:自动;目前为objective-c(gdb)

这是堆栈跟踪:
这里缺少完整的错误信息是最好的猜测:

可能
[self-imageThumbnailLink]
不正确或传递了参数。尝试将语句分成两部分进行调试: 例:


一般来说,在尝试调试错误时,分离复合语句的组件是一个很好的第一步。

请从控制台发布准确完整的错误消息。我只是不知道这一点,但也许您可以尝试在第一行使用[self-setImageThumbnailLink:[NSMutableString stringWithString:imageLink]](stringWithString而不是stringWithFormat)。已使用stringWithString进行更改。但仍会执行错误访问。添加的映像不是控制台错误消息,而是调用堆栈。发布控制台消息后,打开显示控制台-菜单:查看:调试区域:激活控制台。正如我在前面的您回答的评论中所说,错误消息我已编辑错误消息,使其成为clear.仅当前语言:auto;当前为objective-c(gdb)。imagelink在控制台中打印,它肯定不是零。并且仍然获得exc_bad_访问:(.控制台中没有错误消息。仅此而已。当前语言:auto;当前为objective-c(gdb)。并且对特定地址的exc_bad_访问点。parameterPassed是好的,因为当我硬编码imageLink[\u delegate receiveImageLink:@',parser:nil和Parameter:parameterPassed];工作正常。那么我的猜测是,imageLink已经通过arc释放了?在第一行设置图像链接时,可以尝试stringWithString而不是stringWithFormat?或者只设置字符串:
[self-setImageThumbnailLink:imageLink]
stringWithString
除了在本例中创建一个可变字符串外,没有任何好处。
NSLog(@"parameterPassed: %@", parameterPassed);
NSString *imageLink = [self imageThumbnailLink];
NSLog(@"imageLink: %@", imageLink);
[_delegate receiveImageLink:imageLink withParser:nil withParameter:parameterPassed];