Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MyClass(int a, String str){//constructor
- this.a = a;
- this.str = str;
- // i am loking for similar way in obj-C as follows
- this.x = a*5;
- this.y = 'nothing';
- }
- - (MyClass *)init {
- if (self = [super init]) {
- a = 4;
- str = @"test";
- }
- return self;
- }
- @interface YourClass : NSObject {
- NSInteger a;
- NSInteger x;
- NSString *str;
- NSString *y;
- }
- - (id)initWithInteger:(NSInteger)someInteger string:(NSString *)someString;
- @end
- - (id)initWithInteger:(NSInteger)someInteger string:(NSString *)someString {
- if (self = [super init]) {
- a = someInteger;
- str = [someString copy];
- x = a * 5;
- y = [@"nothing" retain];
- }
- return self;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement