【发布时间】:2012-03-18 18:26:00
【问题描述】:
大家好,我已经实现了如下代码,我得到了如下所示的 NSMutableArray 项目,但是当我将数组项目上传到它显示的表视图时 使用引导服务器进行接触测试。错误:未知错误代码。 这通常意味着该进程的另一个实例已经在运行或挂在调试器中。(gdb)。因此,请提供将 NSMutableArray 项目颠倒到 iphone 中的 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)
-
(void)viewDidLoad {
myTableView.delegate=self; myTableView.dataSource=self; myTableView.separatorStyle= UITableViewCellSeparatorStyleNone;
myTableView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"list.png"]]; myTableView.scrollEnabled=YES; 数组=[NSMutableArray 分配];
[超级viewDidLoad];
[自测]; // 在加载视图后做任何额外的设置,通常是从一个笔尖。 }
(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 返回 1;
}- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section { 返回[数组计数]; }
-(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];
}
}
-(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>>ContactNameis:
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);
}
【问题讨论】:
标签: iphone