Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

TenaciousG

macrumors newbie
Original poster
Oct 14, 2009
6
0
Hi!
When restoring my application state from NSUserdefaults, I call a method in my ViewController which updates properties on controls in the view. These changes do not show up in the view, however. From my understanding of KVO the controls should update in the view as they are bound to synthesized properties in my viewmodel.
Can anyone spot the error?

ViewModel .m :
Code:
...
- (void)restoreCalendarWithSelectionArray:(NSArray *)selectionArray
{
	for (int i = 0; i < [selectionArray count] -1; i++) {
		//update the selected ones
		if ([[selectionArray objectAtIndex:i] integerValue] == 1)
		{
			switch (i) {
				case 0:
					button1.hidden = TRUE;
					button1.enabled = FALSE;
					imageView.hidden = FALSE;
					 [imageView setImage:image2];
					break;
...


ViewModel .h:

Code:
...
@interface MyViewController : UIViewController{

	UIImageView *imageView;
	
	UIImageView *animation;

	UIImage *image1;
	
	UIImage *image2;
	
	AVAudioPlayer *audioPlayer;
	
	SystemSoundID currentSoundFXID;
	
	UIButton *button1;
	UIButton *button2;
	UIButton *button3;
}

@property (nonatomic, retain) IBOutlet UIImageView *imageView;

@property (nonatomic) SystemSoundID currentSoundFXID;

@property (nonatomic, retain) IBOutlet UIButton *button1;
@property (nonatomic, retain) IBOutlet UIButton *button2;
@property (nonatomic, retain) IBOutlet UIButton *button3;
...
 
At what point is restoreCalendarWithSelectionArray called?

Are you sure that the controls exist at that point?

What value does button1 have when that method is called?
 
restoreCalendarWithSelectionArray is called from AppDelegates applicationDidFinishLaunching, so I assume the controls are loaded by then.

I'm at work now, can't remember what value the button1 has when called, but I can check later.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.