我正在制作下载排队系统来下载视频。 处理下载的排队代码在另一个viewconntroller中。 现在我的问题是如何将下载的URL传递给另一个视图,而无需像这样推送到另一个视图控制器:
ViewConntroller *View = [[ViewConntroller alloc] init]; view.url = "" [self presentModalViewController:View animated:NO];我也知道代表们有一种方法,但是你也不必为了被召唤的观点而受到重视吗?
编辑我有一个NSURL ,我想发送到另一个viewconntroller。 我知道有协议的方法或上面的方法。 但是我不想提供viewconntroller来发送信息。 我只想在按下按钮后立即发送它而不进入视图本身
I am making a download queueing system to download videos. The queueing code to handle the downloads is in another viewconntroller. Now my question is how can i pass the URL of the download to the other view without pushing to another view controller like this:
ViewConntroller *View = [[ViewConntroller alloc] init]; view.url = "" [self presentModalViewController:View animated:NO];I also know there is a way through delegates but don't you also have to weight for the view to be called upon aswell?
EDIT I have an NSURL in which i want to send to another viewconntroller. I know there is the method of Protocols or the method above. However i do not want to present a viewconntroller to send the info. I just want to send it as soon as the button is pressed without going to the view itself
最满意答案
我不想提供viewconntroller来发送信息。 我只想在按下按钮后立即发送它而不进入视图本身
通常,您不能这样做:您可以将数据发送回视图控制器链,但只有在您呈现发送数据的视图控制器时才可以向前发送数据。
您需要采用不同的方法来解决您的问题:不是将信息发送到另一个视图控制器,而是将该数据发送到公共场所,一旦呈现它就可以被另一个视图控制器找到。 这个“共同的地方”通常被称为模型 (在模型 - 视图 - 控制器意义上)。 使用URL队列创建单个对象,并从第一个视图控制器调用其addUrl:方法。 然后,第二个视图控制器可以调用getUrlQueue方法来检查所有排队的URL。
I figured it out and in then end i sent a url through the calling of a -(void) statement form another view.
For example:
In the secondviewconntroller.h file i would set a void statement...
-(void)addDownloadRequest:(NSString *)request;This line of code means it can be called upon in other class and viewconntrollers.
Then in my secondviewconntroller.m file i would set the -(void) with the function i want to preform when it has been called so in my case i wanted to use the url to download so...
-(void)addDownloadRequest:(NSString *)request{ NSLog(@"Called"); NSString *URL = request; ///Download code here now i have the URL }The code above gets the sent URL in the form as a string called request and then sets the URL variable to the sent string called request.
In my first viewconntroller I then need to call the -(void) statement so I...
secondviewconntroller *theVIEW=[[secondviewconntroller alloc]init]; [theVIEW addDownloadRequest:@"The URL or STRING wanting to be sent"];This code I place in an -(IBAction) which allowed me to send the variable or string when i called upon the action. This successfully allowed the download URL to be sent through class.
Thanks for all of your help.
更多推荐
发布评论