1

SKShapeNode があり、形状を RoundedRectangle として設定していますが、コードを分析すると、オブジェクトのリークの可能性があるという警告が表示されます。

私のinterfaceFileは次のとおりです:

#import <SpriteKit/SpriteKit.h>

@interface letterSpace : SKShapeNode

-(instancetype) initWithCharacter:(NSString *)character xPosition:(float)x yPosition:(float)y device:(NSString *)device;
    @property(nonatomic, assign) BOOL occupied;
    @property(nonatomic, assign) BOOL whiteSpace;
    @property(nonatomic, retain) NSString *character;
    @property (atomic) float secondLineX;
    @property (atomic) float secondLineY;


@end

そして、実装は

 #import "letterSpace.h"

@implementation letterSpace
-(instancetype) initWithCharacter:(NSString *)character xPosition:(float)x yPosition:(float)y device:(NSString *)device{
    self = [super init];
        if(self){

            if ([device isEqualToString:@"IPHONE"]) {
                [self setPath:CGPathCreateWithRoundedRect(CGRectMake(0, 0, 30, 2), 1, 1, nil)]; // Potential Leak of an object on this line
                _secondLineX = 36*8;
                _secondLineY = -36;
            }else{
                [self setPath:CGPathCreateWithRoundedRect(CGRectMake(0, 0, 60, 3.5), 1, 1, nil)]; // Potential Leak of an object on this line
                _secondLineX = 575;
                _secondLineY = -71;
            }
            self.strokeColor = [UIColor clearColor];
            if ([character  isEqual: @" "]) {
               self.occupied = TRUE;
               self.fillColor = [UIColor clearColor];
               self.character = character;
               self.whiteSpace = TRUE;
            }else{
                self.whiteSpace = FALSE;
                self.occupied = FALSE;
                self.fillColor = [UIColor colorWithRed:80.0f/255.0f
                                                green:227.0f/255.0f
                                                                 blue:194.0f/255.0f
                                                                alpha:1];
            }
            if (y <8) {
                self.position = CGPointMake(x, 0);
            }
            else{
                self.position = CGPointMake(x - _secondLineX, _secondLineY);
            }


            self.name = character;
        }
        return self;
    }

@end

このリークを解決する方法はありますか? または何が原因ですか?

4

1 に答える 1