0
您好,我有一个问题,将数值从其他班级调整到一个班级。基本上在我的项目中,我有一个班级placeTableView这是表视图类。通过授权从班级发送数据时出现问题
in placesTableView.m
{
mapView *map=[[mapView alloc]init];
[email protected]"london";
}
mapView.h - a class where delegate is defined and from this class i want to send data to confirmController
@protocol mapViewDelegate;
@interface mapView : UIViewController {
id <mapViewDelegate> delegate;//
}
@property (nonatomic, assign) id delegate;//
@end
@protocol mapViewDelegate <NSObject>//
-(void)sendAStringToAnotherView:(NSString*)string;
@end
mapView.m
@synthesis townName;
-(void)viewDidLoad{
label.text=townName;//townName is getting value from previous view n showing here.
NSLog(@"%@",townName);//it shows value of townName so townName definetly contains value
// NSString *a=[NSString stringWithFormat:@"%@",townName];
[delegate sendAStringToAnotherView:townName]; // this is sending method. i think problem is here
}
confirmController.m - 在数据发送
-(void)viewDidLoad{
mapView *myViewControllerPointer=[[mapView alloc] init];
myViewControllerPointer.delegate = self;//
[self.view addSubview:self.myViewControllerPointer.view];
}
-(void)sendAStringToAnotherView:(NSString*)string
{
//displays the string as console output
NSLog(@"lolo%@", [NSString stringWithFormat:@"%@",string]); // i want to show values here
}
现在我想显示townName在confirmController
从MapView的一类。但它显示为空。但在mapView
如果我使用字符串代替townName它显示在这里confirmController
。
好的你说我必须在应用程序委托类中声明变量。并再次声明它们并将它们的属性设置在mapView类和mapView.m文件中,我可以将值放入它们中。并在confirmController类中我想访问它们,我可以访问他们使用应用程序变量?如何请更多地阐述 –
或者我必须在应用程序委托类中设置属性n合成? –
我在应用程序委托类设置属性和sysnthsis那里设置变量。现在在我的发件人班如何设置值?我在应用程序委托类中声明的变量是globalVariable。但在发件人类globalVariable是showin未声明? –