Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void) saveSettings
- {
- NSString *path = [[NSBundle mainBundle] pathForResource:@"settings" ofType:@""];
- if (music)
- {
- [correctSettingArray removeObjectAtIndex:0];
- [correctSettingArray addObject:@"music = 1"];
- }
- else
- {
- [correctSettingArray removeObjectAtIndex:0];
- [correctSettingArray addObject:@"music = 0"];
- }
- if (sfx)
- {
- [correctSettingArray removeObjectAtIndex:1];
- [correctSettingArray addObject:@"sfx = 1"];
- }
- else
- {
- [correctSettingArray removeObjectAtIndex:0];
- [correctSettingArray addObject:@"sfx = 0"];
- }
- if (vibration)
- {
- [correctSettingArray removeObjectAtIndex:0];
- [correctSettingArray addObject:@"vibration = 1"];
- }
- else
- {
- [correctSettingArray removeObjectAtIndex:0];
- [correctSettingArray addObject:@"vibration = 0"];
- }
- [correctSettingArray writeToFile:path atomically:true];
- }
- [[NSUserDefaults standardUserDefaults] setBool:vibrationBool forKey:@"vibrationKey"];
- BOOL vibrationBool = [[NSUserDefaults standardUserDefaults] boolForKey:@"vibrationKey"];
- [NSNumber numberWithBool:BOOLATR]
- BOOLATR = [[correctSettingArray objectAtIndex:X] boolValue]
- [dictionary setValue:[NSNumber numberWithBool:BOOLATR] forKey:@"BOOLATR"];
- BOOLATR = [[dictionary valueForKey:@"BOOLATR"] boolValue]
- - (id)initWithCoder:(NSCoder *)decoder
- {
- self = [super init];
- if (self) {
- if ([decoder containsValueForKey:@"sunNeverSet"])
- self.sunNeverSet = [NSNumber numberWithBool:
- [decoder decodeBoolForKey:@"sunNeverSet"]];
- }
- return self;
- }
- - (void)encodeWithCoder:(NSCoder *)coder
- {
- if (sunNeverRise) [coder encodeBool:[sunNeverRise boolValue]
- forKey:@"sunNeverRise"];
- }
- NSMutableData *data = [[NSMutableData alloc] init];
- NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc]
- initForWritingWithMutableData:data];
- [archiver encodeRootObject:myObjectImplementingNSCoding];
- [archiver finishEncoding];
- [data writeToFile:path atomically:YES];
- NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc]
- initForReadingWithData:data];
- id myObjectImplementingNSCoding = [[unarchiver decodeObject] retain];
- [unarchiver finishDecoding];
Add Comment
Please, Sign In to add comment