Hi all,
Does anyone know how to add a property in objective c - but that property is also a custom made class?
For instance, I made this class:
Where...
So basically whenever I init & alloc the Person class, it gets setup with personAge as 26 and personName as Jamie.
Now I want to create a bank account class which contains a person property:
Where...
Now - my issue is this:
1) In the BankAccount class, where do I alloc & init the Person class?
Many thanks for your help in advance!
Does anyone know how to add a property in objective c - but that property is also a custom made class?
For instance, I made this class:
Code:
@interface Person : NSObject
@property NSString *personName;
@property NSNumber *personAge;
-(id)init;
@end
Where...
Code:
@implementation Person
@synthesize personAge, personName;
-(id)init{
self = [super init];
if(self){
self.personAge = [NSNumber numberWithInt:26];
self.personName = @"Jamie";
}
return self;
}
@end
So basically whenever I init & alloc the Person class, it gets setup with personAge as 26 and personName as Jamie.
Now I want to create a bank account class which contains a person property:
Code:
@interface BankAccount : NSObject
@property NSNumber *bankAccNumber;
@property (nonatomic) Person *thePerson;
-(id)init;
@end
Where...
Code:
@implementation BankAccount
@synthesize thePerson = _thePerson;
@synthesize bankAccNumber;
-(id)init{
self = [super init];
if(self){
bankAccNumber = [NSNumber numberWithInt:999];
}
return self;
}
@end
Now - my issue is this:
1) In the BankAccount class, where do I alloc & init the Person class?
Many thanks for your help in advance!