如何在目标c中调用[[NSBundle mainBundle] appStoreReceiptURL]时解决内存泄漏?

时间:2019-02-14 07:47:28

标签: objective-c macos memory-leaks

我在使用此特定行NSURL *constantURL = [[NSBundle mainBundle] appStoreReceiptURL];的仪器进行检查时遇到了内存泄漏 此行用于验证Appstore收据

inline static NSData *GetConstantData(void)
{
    NSURL *constantURL = [[NSBundle mainBundle] appStoreReceiptURL];
    NSData *constantData = [NSData dataWithContentsOfURL:constantURL];
    if (!constantData) {
       [NSException raise:@"MacAppStore Constant Validation Error" format:@"Failed to fetch the MacAppStore constant.", nil];

    }
    return constantData;
}

这是this乐器中的图像

有什么建议吗?

1 个答案:

答案 0 :(得分:-1)

尝试[NSData dataWithContentsOfURL:options:error:],或尝试将constantData移到外部。