Iphone 未知类型名称';TransportViewController';
这可能是一个简单的错误,但我似乎无法找出错误的原因Iphone 未知类型名称';TransportViewController';,iphone,objective-c,ios,xcode4.3,Iphone,Objective C,Ios,Xcode4.3,这可能是一个简单的错误,但我似乎无法找出错误的原因未知类型名称“TransportViewController”。我正在尝试将xCoor和yCoor(2double值)传递给我的第二个视图,即TransportViewController。这是我的密码: TransportViewController *xCoor; TransportViewController *yCoor; @property (retain, nonatomic) TransportViewController *xCo
未知类型名称“TransportViewController”
。我正在尝试将xCoor和yCoor(2double
值)传递给我的第二个视图,即TransportViewController。这是我的密码:
TransportViewController *xCoor;
TransportViewController *yCoor;
@property (retain, nonatomic) TransportViewController *xCoor;
@property (retain, nonatomic) TransportViewController *yCoor;
这4行给了我一个错误
MapViewController.h文件
#import "TransportViewController.h"
@interface MapViewController : UIViewController{
TransportViewController *xCoor;
TransportViewController *yCoor;
}
@property (retain, nonatomic) TransportViewController *xCoor;
@property (retain, nonatomic) TransportViewController *yCoor;
#import "TransportViewController.h"
@implementation MapViewController
@synthesize xCoor;
@synthesize yCoor;
.
.
.
- (IBAction) publicTransportAction:(id)sender{
TransportViewController *view = [[TransportViewController alloc] initWithNibName:nil bundle:nil];
self.xCoor = view;
self.yCoor = view;
xCoor.xGPSCoordinate = self.mapView.gps.currentPoint.x;
yCoor.xGPSCoordinate = self.mapView.gps.currentPoint.y;
[self presentModalViewController:view animated:NO];
}
#import "MapViewController.h"
@interface TransportViewController : UIViewController<UITextFieldDelegate>
{
double xGPSCoordinate;
double yGPSCoordinate;
}
@property(nonatomic)double xGPSCoordinate;
@property(nonatomic)double yGPSCoordinate;
@end
MapViewController.m文件
#import "TransportViewController.h"
@interface MapViewController : UIViewController{
TransportViewController *xCoor;
TransportViewController *yCoor;
}
@property (retain, nonatomic) TransportViewController *xCoor;
@property (retain, nonatomic) TransportViewController *yCoor;
#import "TransportViewController.h"
@implementation MapViewController
@synthesize xCoor;
@synthesize yCoor;
.
.
.
- (IBAction) publicTransportAction:(id)sender{
TransportViewController *view = [[TransportViewController alloc] initWithNibName:nil bundle:nil];
self.xCoor = view;
self.yCoor = view;
xCoor.xGPSCoordinate = self.mapView.gps.currentPoint.x;
yCoor.xGPSCoordinate = self.mapView.gps.currentPoint.y;
[self presentModalViewController:view animated:NO];
}
#import "MapViewController.h"
@interface TransportViewController : UIViewController<UITextFieldDelegate>
{
double xGPSCoordinate;
double yGPSCoordinate;
}
@property(nonatomic)double xGPSCoordinate;
@property(nonatomic)double yGPSCoordinate;
@end
TransportViewController.h文件
#import "TransportViewController.h"
@interface MapViewController : UIViewController{
TransportViewController *xCoor;
TransportViewController *yCoor;
}
@property (retain, nonatomic) TransportViewController *xCoor;
@property (retain, nonatomic) TransportViewController *yCoor;
#import "TransportViewController.h"
@implementation MapViewController
@synthesize xCoor;
@synthesize yCoor;
.
.
.
- (IBAction) publicTransportAction:(id)sender{
TransportViewController *view = [[TransportViewController alloc] initWithNibName:nil bundle:nil];
self.xCoor = view;
self.yCoor = view;
xCoor.xGPSCoordinate = self.mapView.gps.currentPoint.x;
yCoor.xGPSCoordinate = self.mapView.gps.currentPoint.y;
[self presentModalViewController:view animated:NO];
}
#import "MapViewController.h"
@interface TransportViewController : UIViewController<UITextFieldDelegate>
{
double xGPSCoordinate;
double yGPSCoordinate;
}
@property(nonatomic)double xGPSCoordinate;
@property(nonatomic)double yGPSCoordinate;
@end
#导入“MapViewController.h”
@接口TransportViewController:UIViewController
{
双xgps坐标;
双余弦坐标;
}
@性质(非原子)双Xgps坐标;
@性质(非原子)双余弦坐标;
@结束
您有一个循环依赖项。简而言之,您已指示编译器:
需要MapViewController.h
TransportViewController.h
- 和
需要TransportViewController.h
MapViewController.h
@class TransportViewController; // << forward declaration instead of inclusion
@interface MapViewController : UIViewController {
TransportViewController *xCoor;
TransportViewController *yCoor;
}
@property (retain, nonatomic) TransportViewController *xCoor;
@property (retain, nonatomic) TransportViewController *yCoor;
@end
@class MapViewController; // << not even needed, as MapViewController
// does not exist in this header
@interface TransportViewController : UIViewController<UITextFieldDelegate>
{
double xGPSCoordinate;
double yGPSCoordinate;
}
@property(nonatomic)double xGPSCoordinate;
@property(nonatomic)double yGPSCoordinate;
@end
@class TransportViewController;//感谢您的帮助和建议:)但是对于TransportViewController.h@class MapViewController代码>是必需的,因为我只在这里粘贴了部分代码。