奥凯过去2天,我曾试图把这个人划出。 我有一个控制我财产清单的班子,它被用作单一吨类别,这样它就只能一时即刻进行,而且它有一个其他方法,用来为名单上的人节省价值。
这份名单不管你做什么,都会把 app子从多塔酒吧(即完全关闭)中去掉,然后该名单上的所有价值都被重新set为无效。 然而,该名单并未丢失。
因此,我现在可能想到的是,我把我从文件主编中得出的读写能力价值观夸大了。 我赞同我的法典榜样,你可以把我的错误暴露出来...... 我不敢肯定我还需要做些什么,如果你有任何问题帮助我回答这个问题,那么请让我知道。
任何帮助都会受到极大赞赏,我的孩子们会but你们。
#import "EnginePropertiesController.h"
static EnginePropertiesController *sharedMyManager = nil;
@implementation EnginePropertiesController
@synthesize pSignature;
@synthesize pVersion;
@synthesize rNumber;
@synthesize dVReturned;
@synthesize cacheValue;
@synthesize manu;
@synthesize mod;
@synthesize submod;
#pragma mark Singleton Methods
+ (id)sharedManager {
@synchronized(self) {
if (sharedMyManager == nil)
sharedMyManager = [[self alloc] init];
}
return sharedMyManager;
}
- (id)init {
if (self = [super init]) {
// get paths from root direcory
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
// get documents path
NSString *documentsPath = [paths objectAtIndex:0];
// get the path to our Data/plist file
NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"EngineProperties.plist"];
NSLog(@"myplist path read = %@", plistPath);
// check to see if Data.plist exists in documents
if (![[NSFileManager defaultManager] fileExistsAtPath:plistPath])
{
// if not in documents, get property list from main bundle
plistPath = [[NSBundle mainBundle] pathForResource:@"EngineProperties" ofType:@"plist"];
}
// read property list into memory as an NSData object
NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
NSString *errorDesc = nil;
NSPropertyListFormat format;
// convert static property liost into dictionary object
NSDictionary *tempRoot = (NSMutableDictionary *)[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc];
manu = [cacheValue objectForKey:@"Manu"];
mod = [cacheValue objectForKey:@"Mod"];
submod = [cacheValue objectForKey:@"SubMod"];
if (tempRoot && [tempRoot count]){
// assign values
self.pVersion = [tempRoot objectForKey:@"PSignature"];
self.pVersion = [tempRoot objectForKey:@"PVersion"];
self.rNumber = [tempRoot objectForKey:@"RNumber"];
self.dVReturned = [tempRoot objectForKey:@"DVReturned"];
cacheValue = [tempRoot objectForKey:@"Cache Value"];
}
}
return self;
}
- (void) saveData:(NSString *)methodName pSignature:(NSString *)TemppSignature pVersion:(NSNumber *)TemppVersion rNumber:(NSNumber *)TemprNumber dVReturned:(NSNumber *)TempdvReturned cacheValue:(NSNumber *)cValue
{
// get paths from root direcory
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
// get documents path
NSString *documentsPath = [paths objectAtIndex:0];
// get the path to our Data/plist file
NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"EngineProperties.plist"];
// set the variables to the values in the text fields
self.pSignature = TemppSignature;
self.pVersion = TemppVersion;
self.rNumber = TemprNumber;
self.dVReturned = TempdVReturned;
//This checks with methodName I would like to save the value from
//The reason for this is there are 3 different cache values I get at seperate times to save This if statment just makes sure they are in the correct order.
if ([methodName isEqualToString:@"Getmanu"]) {
self.manu = cValue;
} else if ([methodName isEqualToString:@"GetMod"]) {
self.mod = cValue;
} else if ([methodName isEqualToString:@"GetSubMod"]) {
self.submod = cValue;
}
//Set up cacheValue Dictionary that will be added to the property list root dictionary
self.cacheValue = [NSDictionary dictionaryWithObjectsAndKeys:
manu, @"Manu",
mod, @"Mod",
subMod, @"SubMod", nil];
//Pass appropriate values into plist
NSDictionary *plistDict = [NSDictionary dictionaryWithObjectsAndKeys:
protocolSignature, @"Protocol Signature",
pVersion, @"Protocol Version",
rNumber, @"Request Number",
dVReturned, @"Data Version returned",
cacheValue, @"Cache Value", nil];
NSString *error = nil;
// create NSData from dictionary
NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:plistDict format:NSPropertyListXMLFormat_v1_0 errorDescription:&error];
// check is plistData exists
if(plistData) {
// write plistData to our Data.plist file
[plistData writeToFile:plistPath atomically:YES];
} else {
NSLog(@"Error in saveData: %@", error);
}
}
@end