I have an app where I need to track the last button pressed at all times. So I have implemented this method:
-(void) lastButtonPressed: (id)sender
{
lastButtonPressed = (UIButton *)sender;
}
Then when any button gets pressed I call:
[self lastButtonPressed = xButton];
Works perfect. But now I am working on archiving all of the objects in my app when the view disappears or closes to then unarchive it and UIButton doesn't conform to NSCopying or NSCoding. I have read that I can subclass UIButton and define the methods but I am stuck there.
So when my app closes or the view disappears I want to save the lastButtonPressed.
I created a new class called BIDPersistence to hold my archived data. In my app's view controller I have a saveData method where I save my data. I get an error on the last line shown below because UIButton doesn't conform.
BIDPersistence *persistence = [[BIDPersistence alloc] init];
persistence.field1 = [NSNumber numberWithDouble:double1];
persistence.field2 = [NSNumber numberWithDouble:double2];
persistence.field3 = display.text;
persistence.field4 = tapeDisplay.text;
persistence.field5 = [NSNumber numberWithBool:continueTape];
persistence.field6 = [NSNumber numberWithBool:newDouble];
persistence.field7 = lastButtonPressed;
Any help appreciated.