iOS 属性传值要注意的几个问题

2019-02-25  本文已影响0人  Dust52100

从firstViewController 传值到 secondViewController,注意以下几点:

1.该属性比如:text ,要在 secondViewController中声明,并且是在.h中声明,在.m中声明是不可见的

2.在firstViewController 要 #import"secondViewController.h"

3.在firstViewController 中,要在实例化secondViewController之后,紧接着赋值,比如secondViewController.text = XXX;

```

#import "ViewController.h"

#import "Person.h"

#import "Lawyer.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {

    Person* laowang = [Personnew];

    Lawyer* lawyer = [Lawyernew];

    laowang.person_delegate= lawyer;

    if([lawyerrespondsToSelector:@selector(getMoney:value:)]) {

        [laowangwantMoneyBack];

    }

}

@end

```

上一篇 下一篇

猜你喜欢

热点阅读