代码之家  ›  专栏  ›  技术社区  ›  StealthRT

访问任何类中的全局变量

  •  -1
  • StealthRT  · 技术社区  · 15 年前

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

    “txtapDelegate”可能不响应“-tcn” “txtpDelegate”可能不响应“-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文件的头文件,其中包含两个函数。代码可以工作,但我真的想解决警告问题。

    任何帮助都可以很好地解决我的这个问题。)

    戴维

    2 回复  |  直到 15 年前
        1
  •  2
  •   Alex Repty    15 年前

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

    - (NSString *)TCN;
    - (NSString *)TID;
    

    如果这不是问题的原因,请在此处发布头文件,以便我们检查它。

        2
  •  0
  •   mouviciel    15 年前

    如何在头中声明这两个函数?

    它们应该属于 TxtAppDelegate 类或协议。如果你选择协议, txtp委派 接口应该提到它符合那个协议。