I have an NSURL
object in ScanViewController
class and pass it to the ListViewController
class.
NSURL *url = [NSURL URLWithString:@"http:// some url"];
I am using xib's in my project and can't find an alternative for
[self.storyboard instantiateViewControllerWithIdentifier:]
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
if(error || !data)
{
NSLog(@"JSON NOT posted");
}
else
{
NSLog(@"JSON data posted!");
id jsonObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:Nil];
if([jsonObject respondsToSelector:@selector(objectForKey:)])
{
NSDictionary *dictionaryForUserID = [jsonObject valueForKey:@"ProjID"];
NSLog(@" Project Id = %@", dictionaryForUserID);
NSURL *urlToDisplayInListView = [NSURL URLWithString:[NSString stringWithFormat:@"http://some url/%@", dictionaryForUserID]]; **//Pass this object to other viewcontroller**
}
}
}];
I assume that you're performing a segue from one VC to another. If so, you can do this in your prepareForSegue:sender:
method:
if ([segue.identifier isEqualToString:@"segueToListViewController"]) {
[(ListViewController *)segue.destinationViewController setURL:[NSURL URLWithString:@"http:// some url"]];
}
You have to declare a property in your destination VC to handle the URL, and you will need an accessor method to set that property.
EDIT
As danypata suggested, if you're not using segues, try the following
ListViewController *listViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ListViewControllerIdentifier"];
[listViewController setURL:[NSURL URLWithString:@"http:// some url"]];
[self presentViewController:listViewController animated:YES completion:nil];
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments