Note that there are some explanatory texts on larger screens.

plurals
  1. POAppend Data To NSDictionary
    text
    copied!<p>My app is of type SplitView and I am using <code>UITableView</code> to display the name of sites. In <code>didSelectRowAtIndexPath</code> method, I am using the following the lines of code ::</p> <pre><code>dateString = [formatter stringFromDate:[NSDate date]]; dict = [[NSDictionary alloc] init]; dict = [NSDictionary dictionaryWithObjectsAndKeys: urlString, dateString, nil]; [history addObject:dict]; NSLog(@"dateString: %@", dateString); //will let you know if it's nil or not NSLog(@"urlString : %@", [dict objectForKey:dateString]); NSString *docDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; NSLog(@"docDir is yoyo :: %@", docDir); NSString *spaceFilePath = [docDir stringByAppendingPathComponent:@"space.txt"]; [history writeToFile:spaceFilePath atomically: TRUE]; </code></pre> <p>I am trying to add the url of sites visited alongwith the timestamp into the <code>NSDictionary</code> "dict". I have initialised formatter in <code>viewDidLoad</code> method. History is an array which stores the list of dictionaries.</p> <p>I have used the following lines of code in <code>viewDidLoad</code> method :</p> <pre><code>formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; </code></pre> <p>I want to append the name of the new site visited into the already existing file space.txt.</p> <p>But, however, only one name appears (the last visited site's url). How can I append the newly visited siteNames into my already existing file space.txt? I am unable to sort out this issue. </p> <p>Thanks and Regards.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload