hi all according to below code i am trying to uploading the NSMutableArray items to the tableview but it showing problem like
ContactTesting[1040:f803] * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘ -[NSMutableArray count]: method sent to an uninitialized mutable array object’
** First throw call stack:
(0x13bc052 0x154dd0a 0x13a820b 0x247b 0x1edf2b 0x1f0722 0xa07c7 0xa02c1 0xa328c 0xa7783 0x52322 0x13bde72 0x1d6692d 0x1d70827 0x1cf6fa7 0x1cf8ea6 0x1d8430c 0x124c6 0x12bd6 0x21743 0x221f8 0x15aa9 0x12a6fa9 0x13901c5 0x12f5022 0x12f390a 0x12f2db4 0x12f2ccb 0x122a7 0x13a9b 0x1bc8 0x1b25 0x1)
Basically i am getting NSMutableArray *array items as like
2012-02-29 14:24:20.246 ContactTesting[564:f803] name is->>>>>>> : (
"\n Enrico Gaetani",
"\n J\U00e9r\U00f4me Tredan",
"\n Mike Tsalidis",
"\n Dana Sugarman",
"\n Necip Ozyucel",
"\n Goksel Topbas",
"\n Nizar Abdul-Baki",
"\n Johannes Kanis",
"\n Kara Westhusing",
"\n Andreas Erlacher",
"\n Rudy Van Hoe",
"\n Lars Nygaard",
"\n Juha Karppinen",
"\n Ronan Geraghty",
"\n Luca Venturelli",
"\n Michel N'Guettia",
"\n John Henrik Andersen",
"\n Jos\U00e9 Grilo",
"\n Luis Miguel Garcia Oliva",
"\n Andre Henriksson",
"\n Marc Holitscher",
"\n Lucas Searle",
"\n Ansgar Heinen",
"\n Vasily Malanin",
"\n Marek Zamlynski",
"\n Petr Vasa",
"\n Peter Budai",
"\n Kostyantyn Khrushchelov",
"\n Nicholas Molfetas",
"\n Bogdan Constantinescu",
"\n Peter Jirsak",
"\n Marko Drev",
"\n Petra Cicek",
"\n Dragana Jovic (E-Search)",
"\n Linas Peciura",
"\n Tsvetomir Mitev",
"\n Renat Begaidar",
"\n Pauline Maillard",
"\n Mark Chaban",
"\n Dayana Orlan-Nevo",
"\n Neveen Nassif",
"\n Francois Smith",
"\n Jeroen Unger",
"\n Kris Vandermeulen",
"\n Claus Petersen",
"\n Riku Reimaa",
but when i am using the tableView methods it quit the functionality so how to solve the problem give the solution it is too urgent for me in iphone
- (void)viewDidLoad
{
[super viewDidLoad];
[self testing];
array=[NSMutableArray alloc];
myTableView.delegate=self;
myTableView.dataSource=self;
myTableView.separatorStyle= UITableViewCellSeparatorStyleNone;
myTableView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"list.png"]];
myTableView.scrollEnabled=YES;
// Do any additional setup after loading the view, typically from a nib.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {
return [array count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
//here you check for PreCreated cell.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
//Fill the cells...
cell.textLabel.text = [array objectAtIndex: indexPath.row];
//yourMutableArray is Array
return cell;
}
-(void)testing{
// NSLog(@">>>>>>>>>>>>233333");
NSString *jobSearchUrlString = [NSString stringWithFormat:@"http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/Contacts"];
//NSLog(@"url for new articles is = %@",jobSearchUrlString);
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:jobSearchUrlString]];
NSURLConnection *theconnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if (theconnection) {
RoutData = [[NSMutableData alloc] init];
}
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[RoutData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[RoutData appendData:data];
NSString *thexml = [[NSString alloc] initWithData:RoutData encoding:NSUTF8StringEncoding];
NSDictionary *dictXML= [XMLReader dictionaryForXMLString:thexml error:nil];
NSMutableArray *arrStation = [[dictXML objectForKey:@"feed"] objectForKey:@"entry"] ;//this would return the array of station dictionaries
// for (int i=0; i<[arrStation count]; i++) {
// NSLog(@"--->>>ContactNameis:<<<---- %@",[[[[[arrStation objectAtIndex:i] objectForKey:@"content"] objectForKey:@"m:properties"] objectForKey:@"d:ContactName"] objectForKey:@"text"]);
array=[[NSMutableArray alloc]init];
for (int i=0; i<[arrStation count]; i++){
NSString *str=[[[[[arrStation objectAtIndex:i] objectForKey:@"content"] objectForKey:@"m:properties"] objectForKey:@"d:ContactName"] objectForKey:@"text"];
// NSlog(@"name is : %@",str);
//NSLog(@"name is->>>>>>> : %@",str);
[array addObject:str];
NSLog(@"name is->>>>>>> : %@",array);
}
// NSString *str=[[arrStation objectAtIndex:i ] objectForKey:@"d:ContactName"];
//NSLog(@"8********************8%@",[[arrStation objectAtIndex:i ] objectForKey:@"d:ContactName"]);
//NSLog(@"--->>>id is ::<<<---- %@",[[[[[arrStation objectAtIndex:i] objectForKey:@"content"] objectForKey:@"m:properties"] objectForKey:@"d:Id"] objectForKey:@"text"]);
//
// NSLog(@"--->>>Emails ::<<<---- %@",[[[[[arrStation objectAtIndex:i] objectForKey:@"content"] objectForKey:@"m:properties"] objectForKey:@"d:Email"] objectForKey:@"text"]);
//
//NSLog(@"--------->>>>>>>>>>><<<<<<<<<<<%@",arrStation);
}
}
After receive all Data , reload the tableView