我是xcode的新手,请帮我纠正我的代码所在的错误,
-(void)XYZ:(NSString *)id1
{
id2 = [id1 intValue];
[self Vehicles:id2];
}
-(NSArray *)Vehicles:(NSInteger) id2
{
NSString *urlString=[NSString stringWithFormat:@"http://www.xxxx.com/xxxx/vehiclelist.php?uid=%d&format=json",id2];
NSURL *url=[NSURL URLWithString:urlString];
NSData *data=[NSData dataWithContentsOfURL:url];
NSError *error;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSArray *results = [json valueForKey:@"posts"];
return results;
}
我从登录vied控制器传递id值,代码为
if(stat!=0&&id2!=0&&[Username length]!=0&&[Password length]!=0)
{
Services *loc = [[Services alloc] initWithNibName:@"Services" bundle:nil];
loc.modalPresentationStyle = UIModalPresentationCurrentContext;
loc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:loc animated:YES completion:Nil];
MyVchicle *about = [[MyVchicle alloc] initWithNibName:@"MyVchicle" bundle:nil];
about.modalPresentationStyle = UIModalPresentationCurrentContext;
about.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:about animated:YES completion:Nil];
[loc XYZ:id1];
}
提前致谢。
答案 0 :(得分:0)
要将数据从一个ViewController发送到另一个ViewController,请按照以下步骤操作:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { DestinationViewController *destController = [segue destinationViewController]; destController.varName = @"passThisValue"; }
这应该让你去。希望这会有所帮助。
您可以参考此链接。