plist / NSMustableDictionary lesen und schreiben

#pragma mark -
#pragma mark write/read NSDictionary <=> PList

- (NSString *)dataFilePath {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docDirectory = [paths objectAtIndex:0];
    return [docDirectory stringByAppendingPathComponent:@"aktuelleArtikel.plist"];
}

- (NSMutableDictionary *)readFromPlist
{
	NSMutableDictionary* plistDict;
	// File exist ?
	if ([[NSFileManager defaultManager] fileExistsAtPath: [self dataFilePath]]){
		NSString *filePath = [self dataFilePath];
		plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
		//	NSString *value;
		//	value = [plistDict objectForKey:@"ProductVersion"];
	} else {
		plistDict = [[NSMutableDictionary alloc] init];
	}

	return plistDict;
}

- (void)writeToPlist:(NSMutableDictionary *) plistDict
{
    NSString *filePath = [self dataFilePath];
	[plistDict writeToFile:filePath atomically: YES];
}

3 thoughts on “plist / NSMustableDictionary lesen und schreiben”

  1. bei
    - (NSString *)dataFilePath {

    kommt der Error: “method definition not in @implementation context” was kann ich da machen?

Leave a Reply

Your email address will not be published. Required fields are marked *