Can we pass a parameter to view did load or view will appear of other class from a class

后端 未结 4 1268
悲&欢浪女
悲&欢浪女 2021-01-27 09:54

Sorry if it is not a standard question, but now your solutions can help me out. In my app, I have two classes: ClassA and ClassB. ClassB

4条回答
  •  旧巷少年郎
    2021-01-27 10:25

    Why don't you declare a property for that?

    @interface ClassB:...
    
    @property (nonatomic, copy) NSString * columnName
    
    @end
    

    and synthesize it in the implementation.

    When you are creating ClassB instance from ClassA then do this,

    ClassB * classB = [[ClassB alloc] initWithNibName:.. bundle:..];
    classB.columnName = theColumnName;
    [self pushViewController:classB animated:YES];
    [classB release];
    

    Make use of this parameter in viewDidLoad.

提交回复
热议问题