IOS:未分配类的属性

IOS:未分配类的属性,ios,class,uiview,Ios,Class,Uiview,我有一个UIView,我称之为“second”,在另一个UIView中称为“one”。 在“second”中,我在Inspector标识(自定义类)中分配了一个类(类“Home.h”)。 全班同学在“第二”观点上做得很好,我没有问题 我现在的任务是如何通过外部类访问Home元素。如果在Home中我设置了一些变量(使用properthy和synthesyze),我无法从另一个类控制它们,因为它告诉我没有分配类Home…我如何解决这种情况 谢谢我对Objective-C和Xcode也很陌生,但我相信

我有一个UIView,我称之为“second”,在另一个UIView中称为“one”。 在“second”中,我在Inspector标识(自定义类)中分配了一个类(类“Home.h”)。 全班同学在“第二”观点上做得很好,我没有问题

我现在的任务是如何通过外部类访问Home元素。如果在Home中我设置了一些变量(使用properthy和synthesyze),我无法从另一个类控制它们,因为它告诉我没有分配类Home…我如何解决这种情况


谢谢

我对Objective-C和Xcode也很陌生,但我相信您所要做的就是将“Home”类(Home.h)的头文件导入到您想要在其中使用的外部类中。在这个外部类中,您必须实例化home类的一个对象。可能是这样的:

/* File: "ExternalClass.h"
* This is the Super-View class of the "Home" class
*/

/* An example using Cocoa rather than Cocoa Touch */
#import <Cocoa/Cocoa.h>

// Imports a quick reference to the class without loading the classes methods
@class Home;

@interface ExternalClass : NSView {

/* This creates an object of class "Home" in which a pointer for the "Home" class can be stored
 * From here all you would have to do is import the 'Home.h' file to the 'ExternalClass.m' file
 * and instantiate home objects and call methods of the 'home' class within the 'ExternalClass.m' files methods
 */
Home *homeObject;

}

您可能必须在ExternalClass.m init方法中初始化变量,具体取决于您在整个程序中使用对象的方式。
homeObject = [[alloc Home] initWithSomeProperties:var1 andMoreProperties:varEtc];