views:

21

answers:

0

Hi all,

I'm facing this problem in which my allocated variabls aren't getting allocated even if their retaincount is increamenting after every alloc/retain.

NSMutableArray *companyArray = [[NSMutableArray alloc]init];

doesn't allocate companyArray but increaments the retain count of companyArray. If I print the description of it, then I'm presented with following explanation:

A syntax error in expression, near `variable)'.

This issue is persistent with nsstrings too. This' only hapening for the variables where I'm storing/retrieving values from nsuserdefaults. Even if this' a memory release issue, then how come even an allocation isn't allocating memory to it?

EDIT: I use the following function where I allocate the array and setting it to nsuserdefaults. I'm usin this array in various files to fetch its values through nsuserefaults. The code compiles fine.

 -(void)saveCustomObject
 {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

NSMutableArray *companyArray = [[NSMutableArray alloc]init];

for(Company *companyObj in companyObjectsArray)
{
    [companyArray addObject: [NSKeyedArchiver archivedDataWithRootObject:companyObj]];
}

[defaults setObject:companyArray forKey:@"companyData"];
[defaults setObject:userCompanyInfo.sessionkey forKey:@"sessionkey"];
[defaults setObject:userCompanyInfo.deviceid forKey:@"deviceid"];
[defaults setObject:userCompanyInfo.userid forKey:@"userid"];
[defaults setObject:userCompanyInfo.service_type forKey:@"service_type"];
[defaults setObject:userCompanyInfo.isduallogin forKey:@"isduallogin"]; 
[defaults setObject:userCompanyInfo.securitycode forKey:@"securitycode"];   

[defaults synchronize];

  }

Can anybody please help?

Thanx in advance.