我的变量在哪里?Objective-C的

alg*_*gro 3 variables objective-c getter-setter

我初始化一个视图(图像)通过:

Image *myImageView = [[Image alloc]init];
    myImageView.myId = randomImageNumber;
    [myImageView initWithImage:myImage];
Run Code Online (Sandbox Code Playgroud)

在Image类中,我执行Log(LOG1)并获取先前设置的randomImageNumber.后来,在同一个类中,我做了第二个Log(LOG2).为什么我的第二个日志不再有价值了?

这是我的类图像的实现文件:

@synthesize myId;
-(id) initWithImage: (UIImage *) anImage
{
    NSLog(@"LOG1%d",myId);
    if ((self = [super initWithImage:anImage]))
    {
        self.userInteractionEnabled = YES;
    }
    return self;
}

}
-(void)touchesBegan...
....
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
  NSLog(@"LOG2%d",myId);
}
Run Code Online (Sandbox Code Playgroud)

"return self"清空我在头文件中声明的myId,并在初始化时设置了myId.我该如何预防呢?

我的Header文件如下所示:

@interface Image : UIImageView 
{
   int myId;
}
@property (assign) int myId;

@end
Run Code Online (Sandbox Code Playgroud)