Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.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
Objective c 公共广播电台_Objective C_Public_Instance Variables_Iboutlet - Fatal编程技术网

Objective c 公共广播电台

Objective c 公共广播电台,objective-c,public,instance-variables,iboutlet,Objective C,Public,Instance Variables,Iboutlet,我想在classB上使用classA的IBOutlet 为什么这不起作用 A.h级 @interface ClassA : UIViewController { @public IBOutlet UILabel* myLabel; } @property (nonatomic, retain) UILabel* myLabel; @end @interface ClassA : UIViewController {} @property (nonat

我想在classB上使用classA的IBOutlet

为什么这不起作用

A.h级

@interface ClassA : UIViewController {
           @public IBOutlet UILabel* myLabel;
           }
@property (nonatomic, retain) UILabel* myLabel;
@end
@interface ClassA : UIViewController {}
@property (nonatomic, retain) IBOutlet UILabel* myLabel; // iVar is created for you by compiler
@end
B.m级

#import "ClassA.h"
#import "ClassB.h" 
@implementation ClassB
           ClassA.myLabel.text =  @"Any String";
#import "ClassA.h"
#import "ClassB.h" 
@implementation ClassB
  -(void)youNeedToBeInsideAMethod {
    classAInstance.myLabel.text =  @"Genius!";
  }
@end
Xcode发送此错误:内部编译器错误:分段错误

或者,还有其他方法可以做到这一点吗?这个问题快把我累死了


提前感谢

您是否直接从XCode复制并粘贴了此内容?您的代码看起来很奇怪。
-ClassB.m不应包含ClassA的实现(这应转到ClassA.m)
-您可能不需要ClassA.myLabel.text,但需要\u ClassA.myLabel.text的实例


如果这样做没有帮助,您能提供更多信息吗?

您是否直接从XCode复制并粘贴了此内容?您的代码看起来很奇怪。
-ClassB.m不应包含ClassA的实现(这应转到ClassA.m)
-您可能不需要ClassA.myLabel.text,但需要\u ClassA.myLabel.text的实例


<>如果这没有帮助,你能提供更多的信息吗?< /p> 嗯,那个代码看起来就像是由C++程序员编写的。不要越过小溪。这是一个古老的问题,但我忍不住要纠正这样一个基本的错误

A.h级

@interface ClassA : UIViewController {
           @public IBOutlet UILabel* myLabel;
           }
@property (nonatomic, retain) UILabel* myLabel;
@end
@interface ClassA : UIViewController {}
@property (nonatomic, retain) IBOutlet UILabel* myLabel; // iVar is created for you by compiler
@end
B.m级

#import "ClassA.h"
#import "ClassB.h" 
@implementation ClassB
           ClassA.myLabel.text =  @"Any String";
#import "ClassA.h"
#import "ClassB.h" 
@implementation ClassB
  -(void)youNeedToBeInsideAMethod {
    classAInstance.myLabel.text =  @"Genius!";
  }
@end

目标!=C++或反之亦然(当然,总是有目标C++)

HMMM,该代码看起来就像是由C++程序员编写的。不要越过小溪。这是一个古老的问题,但我忍不住要纠正这样一个基本的错误

A.h级

@interface ClassA : UIViewController {
           @public IBOutlet UILabel* myLabel;
           }
@property (nonatomic, retain) UILabel* myLabel;
@end
@interface ClassA : UIViewController {}
@property (nonatomic, retain) IBOutlet UILabel* myLabel; // iVar is created for you by compiler
@end
B.m级

#import "ClassA.h"
#import "ClassB.h" 
@implementation ClassB
           ClassA.myLabel.text =  @"Any String";
#import "ClassA.h"
#import "ClassB.h" 
@implementation ClassB
  -(void)youNeedToBeInsideAMethod {
    classAInstance.myLabel.text =  @"Genius!";
  }
@end

目标!=当编译器崩溃时,C++或反之亦然(当然,总是有目标C++)/P>,这是一个相当严重的问题。确保提交一个bug:当编译器崩溃时,这是一个相当严重的问题。确保提交一个bug:我只放了classA的头和classB的实现。我想在B班上使用A班的插座,但你是对的。。。我不能没有ClassA的实例,谢谢你。。。我将寻找另一种方法来解决这个问题,我只放了classA的头和classB的实现。我想在B班上使用A班的插座,但你是对的。。。我不能没有ClassA的实例,谢谢你。。。我将寻找另一种方法来解决这个问题