Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.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 在任何类中访问全局变量_Iphone_Objective C_Xcode - Fatal编程技术网

Iphone 在任何类中访问全局变量

Iphone 在任何类中访问全局变量,iphone,objective-c,xcode,Iphone,Objective C,Xcode,嘿,我一直在想为什么我会收到这样的警告: “TxtAppDelegate”可能不响应“-TCN” “TxtAppDelegate”可能不响应“-TID” 当我尝试使用此代码时: // .h file @interface RootViewController : UITableViewController <UIActionSheetDelegate> { NSString *theCompanyName; NSString *theID; } @property (nonatom

嘿,我一直在想为什么我会收到这样的警告:

“TxtAppDelegate”可能不响应“-TCN” “TxtAppDelegate”可能不响应“-TID”

当我尝试使用此代码时:

// .h file
@interface RootViewController : UITableViewController <UIActionSheetDelegate> {
NSString *theCompanyName;
NSString *theID;
}

@property (nonatomic, retain)NSString *theCompanyName;
@property (nonatomic, retain)NSString *theID;

// .m
NSString *theCompanyName;
NSString *theID;

@synthesize theCompanyName;
@synthesize theID;

TxtAppDelegate *customObjInstance = [[TxtAppDelegate alloc] init];

theCompanyName = [customObjInstance TCN];
theID = [customObjInstance TID];
我已经为包含两个函数的.h文件添加了头。代码可以工作,但我真的想解决警告问题

任何帮助都会很好地解决我的这个问题:


David

如何在标题中声明这两个函数


它们应该属于TxtAppDelegate类或协议的一个类别。如果选择协议,TxtAppDelegate接口应该说明它符合该协议。

虽然查看声明TxtAppDelegate的头文件会更有帮助,但我猜方法声明必须关闭。它们应该是这样的:

- (NSString *)TCN;
- (NSString *)TID;
如果这不是问题的原因,请在这里发布头文件,以便我们可以检查它