Hello, my program normally has a standard background: "black.jpg". In the applicationDidFinishLaunching I did the following:
[window addSubview:viewController.view];
[window makeKeyAndVisible];
viewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"black.jpg"]];
and I have a nice black background. Now I want change my background and for this I made a preference. The defaultValue of the preference is 2, so why does the code not work?:
[window addSubview:viewController.view];
[window makeKeyAndVisible];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
int bla = [prefs stringForKey:@"background_key"];
NSlog(@"%@", bla) //Console says 2!!
if (bla == 2) {
viewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"black.jpg"]];
}
The view doesn't have the custom background. Thanks for your help!