views:

49

answers:

1

Hi!

I have some code, which works perfect in the simulator, but i cant run it on a real iPhone device and i dont get the reason:

- (void)loadView {
 self.title = @"Optionen";
 [super loadView];
}

- (void)viewDidLoad {    
 [super viewDidLoad];

 NSMutableArray *strArray = [NSMutableArray new];
 NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

 if ([[prefs stringForKey:@"facebook"] length] > 0 ) {
  [strArray addObject: [prefs stringForKey:@"facebook"]];
 }
 else {
  [strArray addObject:@"YES"];
 } 


 if ([[prefs stringForKey:@"twitter"] length] > 0 ) {
  [strArray addObject: [prefs stringForKey:@"twitter"]];
 }
 else {
  [strArray addObject:@"YES"];
 }


 if ([[prefs stringForKey:@"pm"] length] > 0 ) {
  [strArray addObject: [prefs stringForKey:@"pm"]];
 }
 else {
  [strArray addObject:@"YES"];
 }

 [facebookSwitch setOn:[[strArray objectAtIndex:0] boolValue]];
 [twitterSwitch setOn:[[strArray objectAtIndex:1] boolValue]];
 [pmSwitch setOn:[[strArray objectAtIndex:2] boolValue]]; 

 [strArray release];
}

-(IBAction) change:(id) sender {
 NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

 if (facebookSwitch.on) {
  [prefs setObject:@"YES" forKey:@"facebook"];  
 }
 else {
  [prefs setObject:@"NO" forKey:@"facebook"];
 }


 if (twitterSwitch.on) {
  [prefs setObject:@"YES" forKey:@"twitter"];  
 }
 else {
  [prefs setObject:@"NO" forKey:@"twitter"];
 }


 if (pmSwitch.on) {
  [prefs setObject:@"YES" forKey:@"pm"];  
 }
 else {
  [prefs setObject:@"NO" forKey:@"pm"];
 }

 [prefs synchronize];
}

Is it a problem with my use of NSUserDefaults?

Thank you for your help.

A: 

You should examine the crash log:

http://stackoverflow.com/questions/3876485/auto-upload-crashlogs-iphone/3877106#3877106

Josh Hinman
Thank you! That will help very much (hopefully), great!
Grt
I check the log files and... everything is ok! It was the fault of my "testperson". Thank you!
Grt