2012-06-27 2 views

답변

4
NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"plist"]; 
contentArray = [NSArray arrayWithContentsOfFile:plistPath]; 

+1

을 시도하려고 – Sumanth

+0

AssamHospitals = [[NSArray를 alloc] initWithContentsOfFile : [[NSBundle mainBundle] \t \t \t \t \t \t \t \t \t \t \t pathForResource : @ "HospitalListAssam"of Type : @ "plist"]]]; – rimpi

+0

귀하의 질문은 무엇입니까? – Sumanth

0

당신은 아마 당신이 대답의 왼쪽에 눈금을 클릭하여 정답을 얻는 경우에 대답을 수락해야이

NSMutableDictionary* dictionary = [[[NSMutableDictionary alloc] init] autorelease]; 

NSError *error; 
// Look in Documents for an existing plist file 
NSArray *paths = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [paths objectAtIndex:0]; 
NSString* metadataPlistPath = [documentsDirectory stringByAppendingPathComponent: 
[NSString stringWithFormat: @"Metadata.plist"]]; 
[metadataPlistPath retain]; 

// If it's not there, copy it from the bundle 
NSFileManager *fileManger = [NSFileManager defaultManager]; 
if (![fileManger fileExistsAtPath:metadataPlistPath]) { 
NSString *pathToSettingsInBundle = [[NSBundle mainBundle] 
pathForResource:@"Metadata" ofType:@"plist"]; 
[fileManger copyItemAtPath:pathToSettingsInBundle toPath:metadataPlistPath error:&error]; 
} 
//Now read the plist file from Documents 
NSString* myPlistPath = [documentsDirectory stringByAppendingPathComponent: 
[NSString stringWithFormat: @"Metadata.plist"] ]; 

dictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:myPlistPath]; 

return dictionary; 
} 

//fetch the data based on key 
- (NSMutableArray*) fetchMetadataArrayForKey:(NSString*)aKey { 
NSMutableArray* arrCategories = [[[NSMutableArray alloc] init] autorelease]; 
NSMutableDictionary* dictionary = [self fetchMetadata]; 

arrCategories = [dictionary valueForKey:aKey]; 

return arrCategories; 

} 
관련 문제