how to check nsuserdefaults is empty or not
<p>i am getting a list of items from sqlite database and place them in an array.</p>

<p>i need to get this array first time my app runs.</p>

<p>for this i am saving this array into NSuserdafaults.</p>

<p>my code is like this</p>

<pre><code>if ([[NSUserDefaults standardUserDefaults] arrayForKey:@"categories"]) {

        [[NSUserDefaults standardUserDefaults] setObject:appdelegate.categoriesList forKey:@"categories"];
        NSLog(@"categorylist&gt;&gt;&gt;&gt;&gt;&gt; %@",appdelegate.categoriesList);
    }
    categoriesArray = [[NSMutableArray alloc]init];
    categoriesArray = [[[NSUserDefaults standardUserDefaults] arrayForKey:@"categories"] mutableCopy];
</code></pre>

<p>then it not entered into if condition.</p>

<p>and if i try with not equal like this.</p>

<pre><code>if (![[NSUserDefaults standardUserDefaults] arrayForKey:@"categories"]) {

        [[NSUserDefaults standardUserDefaults] setObject:appdelegate.categoriesList forKey:@"categories"];
        NSLog(@"categorylist&gt;&gt;&gt;&gt;&gt;&gt; %@",appdelegate.categoriesList);
    }
    categoriesArray = [[NSMutableArray alloc]init];
    categoriesArray = [[[NSUserDefaults standardUserDefaults] arrayForKey:@"categories"] mutableCopy];
</code></pre>

<p>then enter for every build and run.</p>

<p>But i need this for first build and run i mean at installing time.</p>

<p>can any one please help me.</p>

<p>Thank u in advance.</p>

<p>(let me add comment if any one did n't understand my question) </p>
