我知道代表们的工作方式,我知道如何使用它们.
但是我该如何创建呢?
如何在Objective-C中执行回调函数?
我只想看一些完整的例子,我应该理解它.
我正在尝试将数据传递回以前的viewController.
有谁知道如何将数据从ViewController B传递回ViewController A?所以我想要一个字符串'从'BIDAddTypeOfDealViewController转到BIDDCCreateViewController.用户编辑了viewController B,我想在ViewController A中返回已编辑的数据然后我使用它.
我正在使用此答案的"传递数据"部分.我的不同之处:第3点和第6点只是在弹出视图时提及,所以我将该代码放在viewWillDisappear中.我认为这是正确的吗?同样在Point 6,我没有使用nib进行初始化,因为它已经过时了.我正在使用故事板.而且我没有添加最后一行,因为我不相信我会推动它.按我的故事板上的按钮已经让我前进了.
我认为问题可能出现在BIDDCCreateViewController中,我有方法,但我无法运行它.要运行一个方法,它应该[自我方法].我无法做到这一点.那就是我猜的.
它编译并运行良好,没有任何记录,所以我不知道它是否有效.
更新:我无法获得'sendDataToA'方法来执行.
#import <UIKit/UIKit.h>
#import "BIDAddTypeOfDealViewController.h"
@interface BIDDCCreateViewController : UIViewController
@property (strong, nonatomic) NSString *placeId;
- (IBAction)gotoBViewController:(id)sender;
@end
#import "BIDDCCreateViewController.h"
#import "BIDAddTypeOfDealViewController.h"
@implementation BIDDCCreateViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"SUCCESSFULLY PASSED PLACE ID: %@", self.placeId);
}
-(void)sendDataToA:(NSString *)myStringData
{
NSLog(@"Inside sendDataToA");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Your string Data Showing" message:myStringData delegate:self cancelButtonTitle:@"Ok " otherButtonTitles:nil];
[alert show];
}
- (IBAction)gotoBViewController:(id)sender …Run Code Online (Sandbox Code Playgroud) 我需要了解Objective-C中委托方法的用法.谁能指出我正确的来源?
伙计们请让我知道代表和代表方法之间的区别及其差异和用法???
我知道Objective-C的一些内容,而且我正在开发一本iPhone SDK书(来自Obj-C的一本书,它刚刚完成了控制台程序).它试图解释代表虽然它很匆忙,并没有真正理解它试图传达的内容.我对它们是什么以及何时使用它们感到有点困惑.
基本上它说它们是负责代表另一个对象做某些事情的类.
有人在意吗?
谢谢!