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

这是在C#中声明的内容

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

public class Mime
{
//some methods
}
}


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

有任何想法吗?提前致谢。

最佳答案

是的,可以。我在现有课程中使用一个课程。一种是扩展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

10-08 17:50