I have an applicatio in which i am using an nsmutablearray to controll a table view
which i was being programatically created like this.`
tableview = [[UITableView alloc] init];
[tableview setFrame:CGRectMake(self.view.frame.origin.x,44,self.view.frame.size.width, self.view.frame.size.height)];
tableview.dataSource = self;
tableview.delegate = self;
[self.view addSubview:tableview];
self.tableview.rowHeight = 55;
[tableview release];
.then i have an nsmutable array which is an instance array.when it is first loading everything seems to be working fine.i am storing that mutable array to the nsuserdefaults.from the second time onwords i am trying to load the data from the nsuserdefaults array like this.
NSUserDefaults *userslist = [NSUserDefaults standardUserDefaults];
NSArray *arrayObj = [userslist objectForKey:@"userslist"];
NSMutableArray *searchfriendarray1=[NSMutableArray arrayWithArray:arrayObj];
searchfriendarray=searchfriendarray1;
.thats also working .but in a methode i am trying to edit that array and then trying to reload the table the reload table is not getting called.`
[sortedFriendsArray removeAllObjects];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"userslist"];
[[NSUserDefaults standardUserDefaults]synchronize ];
NSDictionary *dictionary = [self.searchfriendarray objectAtIndex:index];
[dictionary setValue:@"offline" forKey:@"TYPE"];
NSUserDefaults *userslist = [NSUserDefaults standardUserDefaults];
[userslist setObject:searchfriendarray forKey:@"userslist"];
`where sorted array was creating from my array after this .But when i call
[self.tableview reloadData]; it is not reloading. Can anybody help me?
Two possible reason for having your tableview not updated ares
Your dataSource array is not updated correctly, so check the size / content of your array when you call reloadData
If your dataSource are updated correctly, probably you are calling reloadData not on the mainThread.
[tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];