I am declaring a Skin class as a variable on my AppDelegate. I only ever assign to it there but later in the app its as if the pointer has been reused by some other code.
I have various declarations but for some reason the item toolBarTint appears to be reassigned (randomly) a different Type when using the debugger at the point of usage later in my app, in the current case UISectionRowData (but changes each time). I do not assign to is anywhere else in my app.
@interface Skin : NSObject {
UIColor *navigationTint;
UIColor *searchBarTint;
UIColor *toolBarTint;
UITableViewStyle tableViewStyle;
CGFloat tableViewCellHeight;
UIColor *tableViewBackgroundColour;
MKPinAnnotationColor *pinColour;
NSString * locationViewFontName;
CGFloat locationViewFontSize;
}
@property (nonatomic,assign) UIColor *navigationTint;
@property (nonatomic,assign) UIColor *searchBarTint;
@property (nonatomic,assign) UIColor *toolBarTint;
@property (nonatomic,assign) UITableViewStyle tableViewStyle;
@property (nonatomic,assign) CGFloat tableViewCellHeight;
@property (nonatomic,assign) UIColor *tableViewBackgroundColour;
@property (nonatomic,assign) MKPinAnnotationColor *pinColour;
@property (nonatomic,retain) NSString * locationViewFontName;
@property (nonatomic,assign) CGFloat locationViewFontSize;
@end
— App delegate define skin
skin = [[Skin alloc] init];
skin.navigationTint = [UIColor colorWithRed:((float) 154 / 255.0f) green:((float) 98 / 255.0f) blue:((float) 176 / 255.0f) alpha:1.0f];
skin.searchBarTint = [UIColor colorWithRed:((float) 154 / 255.0f) green:((float) 98 / 255.0f) blue:((float) 176 / 255.0f) alpha:1.0f];
skin.toolBarTint = [UIColor colorWithRed:((float) 154 / 255.0f) green:((float) 98 / 255.0f) blue:((float) 176 / 255.0f) alpha:1.0f];
skin.tableViewStyle = UITableViewStyleGrouped;
skin.tableViewCellHeight = 60.0;
skin.tableViewBackgroundColour = [UIColor colorWithRed:((float) 154 / 255.0f) green:((float) 98 / 255.0f) blue:((float) 176 / 255.0f) alpha:1.0f];
skin.pinColour = MKPinAnnotationColorRed;
skin.locationViewFontName = @"Helvetica";
skin.locationViewFontSize = 15.0f;
[UIColor colorWithRed:...]returns autoreleased object so its validity is not guaranteed outside scope where you create it. You must retain object for later use (define property with retain attribute instead of assign and not forget to release your ivars in dealloc method).What happened in your case – your
toolBarTintobject was released eventually and then memory was occupied by some other object.