Tuesday, May 7, 2013

NSDictionary dictionaryWithContentsOfURL example ios


Creates and returns a dictionary using the keys and values found in a resource specified by a given URL.
+ (id)dictionaryWithContentsOfURL:(NSURL *)aURL
An URL that identifies a resource containing a string representation of a property list whose root object is a dictionary.
Return Value of [NSDictionary dictionaryWithContentsOfURL]
A new dictionary that contains the dictionary at aURL, or nil if there is an error or if the contents of the resource are an invalid representation of a dictionary.
Discussion of [NSDictionary dictionaryWithContentsOfURL]
The dictionary representation in the file identified by path must contain only property list objects (NSStringNSDataNSDateNSNumberNSArray, or NSDictionary objects). For more details, see Property List Programming Guide. The objects contained by this dictionary are immutable, even if the dictionary is mutable.
Example of [NSDictionary dictionaryWithContentsOfURL]
- (void)viewDidLoad {
    fullData = [NSDictionary dictionaryWithContentsOfURL :url];
    [fullData retain];
    [super viewDidLoad];
Example of [NSDictionary dictionaryWithContentsOfURL]
-(void)getData {
NSURL *url = [NSURL URLWithString: [NSString stringWithFormat:
NSDictionary *data = [NSDictionary dictionaryWithContentsOfURL :url];
NSString *aKey  = [chamUpdateData objectForKey:@"count"];