Guest User

Untitled

a guest
Jan 16th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. -(void) saveSettings
  2. {
  3. NSString *path = [[NSBundle mainBundle] pathForResource:@"settings" ofType:@""];
  4.  
  5. if (music)
  6. {
  7. [correctSettingArray removeObjectAtIndex:0];
  8. [correctSettingArray addObject:@"music = 1"];
  9. }
  10. else
  11. {
  12. [correctSettingArray removeObjectAtIndex:0];
  13. [correctSettingArray addObject:@"music = 0"];
  14. }
  15.  
  16. if (sfx)
  17. {
  18. [correctSettingArray removeObjectAtIndex:1];
  19. [correctSettingArray addObject:@"sfx = 1"];
  20. }
  21. else
  22. {
  23. [correctSettingArray removeObjectAtIndex:0];
  24. [correctSettingArray addObject:@"sfx = 0"];
  25. }
  26.  
  27. if (vibration)
  28. {
  29. [correctSettingArray removeObjectAtIndex:0];
  30. [correctSettingArray addObject:@"vibration = 1"];
  31. }
  32. else
  33. {
  34. [correctSettingArray removeObjectAtIndex:0];
  35. [correctSettingArray addObject:@"vibration = 0"];
  36. }
  37.  
  38. [correctSettingArray writeToFile:path atomically:true];
  39.  
  40. }
  41.  
  42. [[NSUserDefaults standardUserDefaults] setBool:vibrationBool forKey:@"vibrationKey"];
  43.  
  44. BOOL vibrationBool = [[NSUserDefaults standardUserDefaults] boolForKey:@"vibrationKey"];
  45.  
  46. [NSNumber numberWithBool:BOOLATR]
  47.  
  48. BOOLATR = [[correctSettingArray objectAtIndex:X] boolValue]
  49.  
  50. [dictionary setValue:[NSNumber numberWithBool:BOOLATR] forKey:@"BOOLATR"];
  51.  
  52. BOOLATR = [[dictionary valueForKey:@"BOOLATR"] boolValue]
  53.  
  54. - (id)initWithCoder:(NSCoder *)decoder
  55. {
  56. self = [super init];
  57. if (self) {
  58. if ([decoder containsValueForKey:@"sunNeverSet"])
  59. self.sunNeverSet = [NSNumber numberWithBool:
  60. [decoder decodeBoolForKey:@"sunNeverSet"]];
  61. }
  62. return self;
  63. }
  64.  
  65. - (void)encodeWithCoder:(NSCoder *)coder
  66. {
  67. if (sunNeverRise) [coder encodeBool:[sunNeverRise boolValue]
  68. forKey:@"sunNeverRise"];
  69. }
  70.  
  71. NSMutableData *data = [[NSMutableData alloc] init];
  72. NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc]
  73. initForWritingWithMutableData:data];
  74.  
  75. [archiver encodeRootObject:myObjectImplementingNSCoding];
  76. [archiver finishEncoding];
  77. [data writeToFile:path atomically:YES];
  78.  
  79. NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc]
  80. initForReadingWithData:data];
  81. id myObjectImplementingNSCoding = [[unarchiver decodeObject] retain];
  82. [unarchiver finishDecoding];
Add Comment
Please, Sign In to add comment