2012-02-29 40 views
0

大家好,我已經實施了下面的代碼,我得到如下所示的NSMutableArray項目,但是當我上傳數組項目到表格視圖它顯示 ContactTesting與引導服務器。錯誤:未知的錯誤代碼。 這通常意味着此進程的另一個實例已在運行或掛在調試器中(gdb)。所以給解決方案將懸而未決的NSMutableArray項目在iphone中的tableview。與引導服務器如何將NSMutableArray數據項拖到tableview?

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); 

} 


2012-02-29 14:24:20.256 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", 

此我已經實現的tableView碼如圖所示的下方示出

無法註冊com.fitzgerald.-ContactTesting.ContactTesting。錯誤:未知的錯誤代碼。 。 這通常意味着該過程的另一個實例已經運行或掛在調試器(GDB)

  • (無效)viewDidLoad中 {

    myTableView.delegate =自我; myTableView.dataSource = self; myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;

    myTableView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@「list.png」]]; myTableView.scrollEnabled = YES; array = [NSMutableArray alloc];

    [super viewDidLoad];

    [self testing]; //加載視圖後,通常從筆尖執行任何其他設置。 }

  • (NSInteger的)numberOfSectionsInTableView:(UITableView的*)的tableView { 返回1;
    }

  • (NSInteger的)的tableView:(UITableView的*)表numberOfRowsInSection:(NSInteger的)部分{ 返回[陣列計數]; }

- (的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; 

}

- (無效)測試{ //的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]; 
} 

}

- (無效)連接:(NSURLConnection的*)連接didReceiveResponse:(NSURLResponse *)響應 {

[RoutData setLength: 0]; 

} - (無效)連接:(NSURLConnection的* )連接didReceiveData:(NSData *)數據 {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 

//對(INT I = 0;我< [arrStation計數];我++){// 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); 

       } 

回答

相關問題