Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 未知类型名称';TransportViewController';_Iphone_Objective C_Ios_Xcode4.3 - Fatal编程技术网

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(2
double
值)传递给我的第二个视图,即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
实际上,这两种方法在标题中都不是必需的。在这两种情况下都可以使用转发声明

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是必需的,因为我只在这里粘贴了部分代码。