我想创建一个页面表格视图,并且我想在单击任何单元格时执行特定工作!
(例如,当我单击单元格从特定 URL 地址接收 NSString 值时)
这是我的一段代码:
视图控制器.m
@implementation ViewController
@synthesize tables;
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *Number2 = [[NSString alloc]initWithContentsOfURL:[NSURL URLWithString:@"http://192.168.1.104/janatan/filemanager.php?dir=root&foldernum"]];
folderNumber = [Number2 integerValue];
for (int i=0; i < folderNumber; i++)
{
NSString *folderName = [[NSString alloc]initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://192.168.1.104/janatan/filemanager.php?dir=root&folder=%d&name",i]]];
if (!folder)
{
folder = [NSMutableArray array];
}
[folder addObject:folderName];
}
all = [[NSMutableArray alloc]init];
[all addObjectsFromArray:folder];
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if([folder containsObject:[all objectAtIndex:indexPath.row]])
{
[self performSegueWithIdentifier:@"segue2" sender:self];
}
//I want when to click any cell get NSString from this URL:
//"http://192.168.1.104/janatan/filemanager.php?dir=root&**folder=%d**&id"
//(this URL give me id for any folder and any folder is in any cell)
}