1

我有两个VC:StepThreeViewController和QuoteViewController。 我想通过使用委托B/C一旦我有数据,将数据从QuoteViewController传递回StepThreeViewController,我想弹出/关闭QuoteViewController并将数据传递到StepThreViewController。传递数据VC代表iOS

我收到一个错误,发现委托协议没有找到!我遵循YouTube教程,阅读了很多关于StackOverflow的评论,但似乎无法找到错误!

我也确保我的#import头文件在那里。

GitHub的我的代码可以在这里找到: https://github.com/aspirasean/BoxRocket.git

谢谢!

+0

我想你可能错误地上传至Github上。我只看到.h和.m文件。没有项目文件或故事板文件。 – Ricky

+0

@Ricky该项目现在上传到我的git存储库上,但为了防止它崩溃,您需要在AppDelegate.m中输入您自己的Parse API密钥。感谢您的帮助。 – Aspirasean

+0

@瑞奇我让它通过“heightField”,但我把它作为一个占位符。我最终试图从QuoteViewController传回“int quote”,并将其显示在StepThreeViewController的“quoteLabel”中。 – Aspirasean

回答

2

我想这可能并不需要QuoteViewController.h已导入"StepThreeViewController.h“下。我有评论指出,行,可以没有任何错误编译。

#import <UIKit/UIKit.h> 
//#import "StepThreeViewController.h" 
#import "MBProgressHUD.h" 

在情况下,如果你需要使用StepThreeViewControllerQuoteViewController,你可能想看看这篇文章:Cannot find protocol declaration

更新

StepThreeViewController.h你应该: -

@property (nonatomic, strong) QuoteViewController *controller; 

然后在viewDidLoad,你应该

self.controller.delegate=self; 

你将不得不作出的StepThreeViewController是的委托QuoteViewController为了委托方法工作。

要了解更多关于在Objective-C的代表,您可以访问:How do I create delegates in Objective-C?

+0

你知道,那工作!现在我需要弄清楚数据是否真的传回来了。谢谢您的帮助! – Aspirasean

+0

现在我在StepThreeViewController中创建的方法在QuoteViewController中没有被调用,我正在调用[self.delegate transferQuote:@“STRING”];有任何想法吗? – Aspirasean

+0

更新了上面的答案。让我知道它是否有效。 – Ricky