Reputation: 131
I'm new to iPhone development,I want to assign one class in existing class
This is what declare in C#
public partial class UserRegisteration : System.Web.UI.Page
{
//some methods
public class Mime
{
//some methods
}
}
like the above format in Objective-C how to assign one more class in existing class?
Any ideas? Thanks in advance.
Upvotes: 0
Views: 95
Reputation: 10959
Yes you can.I am using one class in existing class . One is extending UIView
and other is extending 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
For getting the static value of SingleControl in MultiLayout . you have to call class method like:
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
Upvotes: 1
Reputation: 949
If I understand your question correctly, you would do this in your interface file:
@interface Mime
//properties and method declarations
@end
@interface UserRegistration : System.Web.UI.Page
@property (strong, nonatomic) Mime *mimeInstance;
@end
and then in the implementation file you implement both like so:
@implementation Mime
//implementation
@end
@implementation UserRegistration
//implementation
@end
Upvotes: 0