在NSData框架中使用ARC的内存泄漏

时间:2013-01-09 06:59:35

标签: objective-c memory-leaks automatic-ref-counting

我无法弄清楚一个内存泄漏。我将添加屏幕截图代码和标记行发生这种情况。

enter image description here

也许有些人可以帮我看看。

感谢。

- (AVAudioPlayer*)getSpeachSoundObject{

    NSString *objectIDString = [NSString stringWithFormat:@"%i", jmObject.objectID];
    NSString * __weak textPlaySource = [DataController getMediaUrlStringForObjectID:objectIDString parentType:PARENT_TYPE_ITEM_AUDIO];
    NSError * error = nil ;

    if (textPlaySource) {

        //NSURL *soundURL = [[NSURL alloc] initFileURLWithPath:textPlaySource];//[NSURL fileURLWithPath:textPlaySource];
        NSData * data = [NSData dataWithContentsOfFile:textPlaySource options:NSDataReadingMapped error:&error ] ;
        textPlaySource = nil;

        NSError *error;

        //speechSound = [[AVAudioPlayer alloc] initWithContentsOfURL:soundURL error:&error];
        AVAudioPlayer *lspeechSound = data ? [[AVAudioPlayer alloc] initWithData:data error:&error ] : nil ;

        data = nil;

        if (error) {
            WLog([NSString stringWithFormat:@"Error creating sound file:%@", error]);
        }

        return lspeechSound;
        //soundURL = nil;
    }

    return nil;
}

0 个答案:

没有答案