How to transfer data from one view to another?

I am doing a system boot to download videos. The queue code for processing downloads is in a different view. Now my question is how to pass the download URL to another view without clicking on another view controller, for example:

 ViewConntroller *View = [[ViewConntroller alloc] init];
    view.url = ""
   [self presentModalViewController:View animated:NO];

I also know that there is a way through delegates, but don't you also need to weigh so that the opinion is called forth?

EDIT I have NSURLone in which I want to send another viewconntroller. I know there is a protocol method or method above. However, I do not want to submit a viewconntroller to send information. I just want to send it as soon as the button is pressed, without going to the view itself

+4
source share
3 answers

I realized this, and in the end I sent the url via a call to an expression of a -(void)different kind.

For example:

In the secondviewconntroller.h file, I would set the void operator ...

-(void)addDownloadRequest:(NSString *)request;

This line of code means that it can be called in another class and viewconntrollers.

Then in my secondviewconntroller.m file I would install -(void)with the function that I want to transform when it was called, so in my case I wanted to use the download URL ...

-(void)addDownloadRequest:(NSString *)request{
    NSLog(@"Called");
    NSString *URL = request;
    ///Download code here now i have the URL
}

The above code sends the URL in the form as a query string, and then sets the URL variable to the sent query string.

In my first viewconntroller, I need to call a statement -(void)so that I ...

secondviewconntroller *theVIEW=[[secondviewconntroller alloc]init];
[theVIEW addDownloadRequest:@"The URL or STRING wanting to be sent"]; 

-(IBAction), , . URL- .

.

+2

viewconntroller . , ,

, : , , .

: , , , . " " ( Model-View-Controller). URL- addUrl: . getUrlQueue URL- .

Illustration

+2

init . - :

@implementation MyViewController {
  id data1;
  id data2;
}
-(id)initWithData1:(id)d1 data2:(id)d2 {
  self = [super init];
  if(self) {
    data1 = d1;
    data2 = d2;
  }
  return self;
}
@end

, .

+1
source

All Articles