Note that there are some explanatory texts on larger screens.

plurals
  1. POsmall trouble in NSUserDefault with strings
    primarykey
    data
    text
    <p>when I save my array every thing is good</p> <pre><code>NSMutableArray *savestring = news; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:savestring forKey:@"savestring"]; [defaults synchronize]; </code></pre> <p>the <code>NSLog</code> here is a titles, around 10 titles (simple from the output):</p> <pre><code>2013-08-19 11:23:13.556 Dr.Saleh[4282:1303] saveString= ( "Sumou Real Estate Company Won The Award of the World Confederation of Business" ) 2013-08-19 11:23:13.558 Dr.Saleh[4282:1303] saveString= ( "Biggest indoor Mapping Projection event" ) 2013-08-19 11:23:13.559 Dr.Saleh[4282:1303] saveString= ( "Sumou Real Estate launches" ) </code></pre> <p>.......etc</p> <p>then when i load the strings it take the last string only this is the loading code:</p> <pre><code>NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSMutableArray *loadstring = [defaults objectForKey:@"savestring"]; [defaults setValue:loadstring forKey:@"savestring"]; news = [defaults mutableArrayValueForKey:@"savestring"]; </code></pre> <p>the <code>NSLog</code> of news give my only the last string save in savestring where is my mistake </p> <p>//==========================================================================//</p> <p>I solve my problem with changing this code</p> <pre><code>NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:savestring forKey:@"savestring"]; [defaults synchronize]; </code></pre> <p>and make it like that </p> <pre><code>NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [[NSUserDefaults standardUserDefaults] setObject:[[[NSUserDefaults standardUserDefaults] objectForKey:@"savestring"] arrayByAddingObject:news] forKey:@"savestring"]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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