I have an initializer with two arguments:
-(id) initWithSourceFrame:(CGRect)sourceViewFrame mappedFrame:(CGRect)mappedViewFrame {
CGRect copy = mappedViewFrame;
self = [super init];
if (self) {
// not able to access mappedViewFrame here..
// copy is ok
// doing initialization here...
}
return self;
}
It seemed to get wrong values from the second argument (mappedViewFrame). When looking for the error, I found out that mappedViewFrame gets destroyed (overridden in memory?). This can be easily observed in the debugger:
Debugger Screenshot on flickr (I cannot post images yet)
The copy is still holding the original values, so using the copy was a workaround in this case. But of course I want to understand why this could happen. The class is a direct subclass of NSObject, the whole project is a OS X native app. The first argument was never destroyed. The problem does not relate to the values passed in. I switched them and it was always the second which was corrupted.
For example, I called the initializer with these example arguments (different from those in the debugger screenshots), and the error occured in the same way:
Mapper *mapper = [[Mapper alloc] initWithSourceFrame:CGRectMake(0, 0, 100, 100) mappedFrame:CGRectMake(0,0, 200,200)];
The method declaration:
-(id) initWithSourceFrame:(CGRect) sourceViewFrame mappedFrame:(CGRect) mappedViewFrame;
I'm somewhat new to Objective-C, so I am sorry if I missed something obvious. However, it looks strange that an argument does not keep valid during method invocation.