ios - 如何在现有课程中分配新课程?

时间:2013-06-06 09:34:34

标签: iphone ios objective-c

我是iPhone开发的新手,我想在现有的课程中分配一个课程

这是在C#中声明的内容

public partial class UserRegisteration : System.Web.UI.Page
{
//some methods

public class Mime
{
//some methods
}
}

像Objective-C中的上述格式一样,如何在现有类中再分配一个类?

有什么想法吗?提前谢谢。

2 个答案:

答案 0 :(得分:1)

是的,你可以。我在现有班级使用一个班级。一个是UIView,另一个是NSObject

<强> MultiLayout.h

    @interface MultiLayout  : UIView
    {
   // methods and properties
    }

    @end

    @interface SingleControl : NSObject
    {
   // methods and properties
    }

    @end

<强> MultiLayout.m

@implementation SingleControl

//methods and variables declaration and property synthesization

@end

@implementation MultiLayout

//methods and variables declaration and property synthesization

@end

用于在MultiLayout中获取SingleControl的静态值。你必须调用类方法,如:

<强> MultiLayout.h

 @interface  MultiLayout : UIView
    {
   // methods and properties
    }

    @end

    @interface SingleControl : NSObject
    {
   // methods and properties
    }

   // add class method
   +(int)getValue;

    @end

<强> MultiLayout.m

    @implementation SingleControl

    // add static value 
    static int values = 100;


    // implement method

   +(int)getValue{
    return values;
    }

    @end

    @implementation MultiLayout

    // call method to get value

     [SingleChoiceControl getValue];

    @end

答案 1 :(得分:0)

如果我理解你的问题,你可以在你的界面文件中执行此操作:

@interface Mime 

//properties and method declarations

@end

@interface UserRegistration : System.Web.UI.Page

@property (strong, nonatomic) Mime *mimeInstance;

@end

然后在实现文件中实现两者:

@implementation Mime 

//implementation

@end

@implementation UserRegistration

//implementation

@end