【发布时间】:2010-11-15 17:23:47
【问题描述】:
首先...如果没有人能回答这个问题也没关系...
因为我不知道如何在正确的描述中提出这个问题
我的程序是从 URL 获取 plist 数据并将其显示在 iphone tableview 上
我的同事给了我两个获取 plist 数据的 URL
所以我有两个 tableviews(tableview1,tableview2)
两个网址(URL1,URL2)
我的tableview1通过URL1得到一个plist1,tableview1前3行有3个内容 p>
例如(row0 id1),(row1 id2),(row2 id3)
当我选择 row0 时,它将跳转到 tableview2 并在导航栏上显示标题 id1
目前为止我能做到...
但是在 tableview2 中,它需要一个像这样的 URL:www.URL2.php?id=1 =>这意味着...
我必须在 URL2 之后添加我的 tableview 标题
获取与 id 1 相关的正确 plist
我的问题是.......URL2 是静态的,如何让它像动态一样获得正确的 URL 地址???
嗯.....第一次我以为我的同事会给我一个像数组数组这样的数据
但这不是...我从不尝试使用动态 URL...
这是 tableview1 中的代码,可让我从 URL 获取 plist
NSURLRequest *theRequest=[NSURLRequest requestWithURL:appDelegate.URL1//I declare the URL at appDelegate.m for some reasons...
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
NSData *returnData = [NSURLConnection sendSynchronousRequest:theRequest
returningResponse:nil error:nil];
NSString *listFile = [[NSString alloc] initWithData:returnData encoding:NSASCIIStringEncoding];
self.array = [listFile propertyList];//I parse the data from array to tablecview
这就是我如何将标题从 Tableview1 解析为 Tableview2
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
TableView2 *tb2 = [[TableView2 alloc]init];
tb2.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
tb2.title = [[[array objectAtIndex:indexPath.row] valueForKey:@"name"]description];
[self.navigationController pushViewController:tb2 animated:YES]; }
有什么想法吗?
嗯......如果有人能回答这个问题或给我一个方向,我将非常感激
非常感谢所有回复和答复!!!
哦...还有一件事,我可以使用 ASIHTTPRequest 来发布数据
但我不知道如何在发布后获取数据...?(这有帮助吗?)
【问题讨论】:
标签: iphone objective-c plist nsurl