I have a textbox with submit button . I need when i press to submit and data in the textbox should be written in the plist . I tried the below code , but nothing is been changing in the plist .I have created a plist with name sample.plist.
-(void) SubmitAction {
NSString *path = [NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *finalPath = [path stringByAppendingPathComponent:@"sample.plist"];
NSMutableDictionary *plistDict = [NSMutableDictionary dictionaryWithContentsOfFile:finalPath];
NSMutableArray *titleArray=[plistDict valueForKey:@"title"];
[titleArray addObject:textbox1.text];
[plistDict setValue:titleArray forKey:@"title"];
[plistDict writeToFile:finalPath atomically:NO];
}
The array created in the plist is below
<plist version="1.0">
<dict>
<key>title</key> <array/>
</dict>
</plist>
please tell what else i need to do ..where is my fault