This question might be off base, but here's the problem I'm having:
I'm trying to run an example from the iPhone SDK, and I'm running into an access violation. I've traced down some behaviour that I think is suspicious.
Here's what the class looks like:
@interface TableViewCell : UITableViewCell {
@private
UILabel *_earthquakeLocationLabel;
UILabel *_earthquakeDateLabel;
UILabel *_earthquakeMagnitudeLabel;
UIImageView *_magnitudeImageView;
}
When I set a breakpoint in
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier
And look at "self" in the debugger, it shows that _earthquakeDateLabel is "0x12", _earthquakeMagnitudeLabel is 0x1000, and the other two are zero. If I try to assign to either of the nonzero ones, I get an access violation.
I'm guessing what's happening is that these have bogus values in them, and when I try to assign to them, that tries to decrement a reference on the bogus value and blows up. But as I said, I'm fairly new to Objective C, so I may be off base.
So my question is, is there anything special about initializing these values that I should be doing? Or any way to assign to the value when it has a bogus value in it?
Some additional information:
So if I assign nil to _earthquakeDateLabel and _earthquakeMagnitudeLabel in initialize, that fixes the problem. But I don't understand why the object is created with values in those fields; I expect them to be nil. The object is being created on the heap:
TableViewCell *cell = [[[TableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];