Teja Swaroop
Teja Swaroop

Reputation: 1159

How To remove a key value from Plist in ios?

I wanted to delete the key value in the Plist. I found answers like to delete the value assigned to it and another is to load a new plist but i need to delete a key value

Upvotes: 1

Views: 5083

Answers (3)

Teja Swaroop
Teja Swaroop

Reputation: 1159

PlistDict is the Dictionary that is loaded in to the plist .By using following code we can remove the key value from the plist.

[plistDict removeObjectForKey:@"Key"];

Dictionary must be a Mutable one(NSMutableDictionary).

Upvotes: 0

user529758
user529758

Reputation:

(assuming this is programming-related)

You can load it into an NSDictionary, remove the key/value pair, then write it back:

NSString *pathToPlist = @"/Users/H2CO3/my.plist";
NSMutableDictionary *plist = [NSMutableDictionary dictionaryWithCOntentsOfFile:pathToPlist];
[plist removeObjectForKey:@"MyKeyIWannaDelete"];
[plist writeToFile:pathToPlist atomically:YES];

Upvotes: 1

Rajesh
Rajesh

Reputation: 483

As of now this is not possible via coding. If you have these kind of scenario's, go with the database. So that, you can delete, what ever the row you want?

Upvotes: 0

Related Questions