2

PersonModel クラスを持つアーク対応プロジェクトがあります。

// .h
@interface PersonModel : NSObject

@property (strong, nonatomic) NSString *photoUrl;
@property (strong, nonatomic) UIImage *photo;
@property (strong, nonatomic) NSString *fio;

@end

// .m
@implementation PersonModel

@synthesize photoUrl;
@synthesize photo = _photo;
@synthesize fio;

- (UIImage *)photo
{
    if (_photo == nil && self.photoUrl) {
        _photo = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.photoUrl]]];
    }

    return _photo;
}

@end

写真ゲッターは gcd を使用して呼び出されます。

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{

    UIImage *cellImage = model.photo;

});

オンライン

_photo = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.photoUrl]]];

Instruments は 100% のメモリ リークを示します。私の知る限り、アークはメインスレッド以外のスレッドでは機能しません。この問題を修正する方法はありますか?

4

0 に答える 0