0
내 pList를 만들 때 사용하는 객체 클래스를 설정했지만 몇 가지 문제가 있습니다. 나는 싱글 톤 디자인 패턴을 사용하고 있기 때문에 한 번에 하나의 인스턴스 만 처리하면된다. ...그러나 pList를 만들려고 시도하지 않습니다.
이상한 이유로 나는 제대로 작동하지 않고 나 자신의 삶을 위해서 나는 이해할 수 없다. 밖으로 왜, 나는 그것이 싱글 톤 디자인 패턴에있는 함께 할 수있는 뭔가가있는 경우는 거기에 그것을 읽는 경우 다른,
#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 (where we will store and fine our plist in the future)
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
// get documents path
NSString *documentsPath = [paths objectAtIndex:0];
// get the path to our plist file
NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"EngineProperties.plist"];
NSLog(@"pList path = %@", plistPath);
// check to see if .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 plist into dictionary object (this is where any saved values get put into
savedEnginePropertiesDict = (NSMutableDictionary *)[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc];
//Load all current values of the property list thats been put into savedEnginePropertiesDict into their variables
if (savedEnginePropertiesDict && [savedEnginePropertiesDict count]){
// assign values
self.sig = [savedEnginePropertiesDict objectForKey:@"Signature"];
self.ver = [savedEnginePropertiesDict objectForKey:@"Version"];
self.num = [savedEnginePropertiesDict objectForKey:@"Number"];
self.dataV = [savedEnginePropertiesDict objectForKey:@"Data"];
self.cache = [savedEnginePropertiesDict objectForKey:@"Cache"];
}
}
return self;
}
이
다음의 PLIST이 상주 할 디렉토리를 생성한다 .. woundering 만드는 오전 그것 .. 그러나 그것의 무엇도하지 않는 것. 그리고 나는 그것이 작동하지 않는 이유를 이해하는 것에 관해서 완전한 손실에있다.
젠장, 그 중 하나가 작동하지 않는 것 같아요 ... 심지어 시뮬레이터에서 애플 리케이션을 삭제하고 그것을 다시 빌드했지만 새로운 번들로 저장했지만 그 중 도움이되지 않았다. –
일했습니다! 나는 틀린 장소에서 그것을 사용하고 있었다. .. wasnt는주의를 기울이고 있었다 :( –