iphone – stringByAppendingString
发布时间:2020-12-14 17:59:40 所属栏目:百科 来源:网络整理
导读:我正在使用 Xcode 4.2故事板. 我被困在这个连接中.这是正确的吗?我要修改的代码在哪里? 实际上我想显示一个新的tableview,具体取决于从上一个tableview传递的变量(“row”). 任何帮助赞赏. self.newrow =row;// row is the variable passed from previous
我正在使用
Xcode 4.2故事板.
我被困在这个连接中.这是正确的吗?我要修改的代码在哪里? 实际上我想显示一个新的tableview,具体取决于从上一个tableview传递的变量(“row”). 任何帮助赞赏. self.newrow =row;// row is the variable passed from previous tableview NSString *urlString = [NSString stringWithFormat: @"http://ipaddress/iphone.php?id="]; NSString *urlStr=@""; urlStr=[urlString stringByAppendingString:newrow]; NSURL *url = [NSURL URLWithString:urlStr]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL: url]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [connection release]; [request release]; 解决方法
由于self.newRow是一个整数,因此您的代码更改为:
NSString *urlStr = [urlString stringByAppendingFormat:@"%i",self.newrow]; 格式将整数转换为字符串表示形式. 几个陈述可以合并而不会失去清晰度: NSString *urlString = [NSString stringWithFormat: @"http://ipaddress/iphone.php?id=%i",self.newrow]; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |