I have a variable usuario of type TuplaUsuario. When I insert its data, I want to initialize NSMutableArray cups to an Array of type TuplaCups. How can I do it?
Here is my code up to date:
TuplaUsuario:
//TuplaUsuario.h:
@interface TuplaUsuario : NSObject
{
NSMutableString* mensaje;
NSString* usuario;
NSString* password;
NSMutableArray* cups;
//More variables
}
//Property for each variable
- (id)initWithString:(NSString *)identifier;
//TuplaUsuario.m:
//Synthesize for each variable
- (id)initWithString:(NSString *)identifier {
if ( self = [super init] ) {
mensaje = [[NSMutableString alloc] initWithString:identifier];
usuario = [[NSString alloc] initWithString:identifier];
password = [[NSString alloc] initWithString:identifier];
cups = [[NSMutableArray alloc] init];
}
return self;
}
TuplaCups:
//TuplaCups.h:
@interface TuplaCups : NSObject {
NSString* cups;
NSString* tarifa;
NSString* direccion;
NSString* nombreUsuario;
NSMutableArray* facturas;
}
//Property for each variable
- (id)initWithString:(NSString *)identifier;
//TuplaCups.m:
//Synthesize for each variable
- (id)initWithString:(NSString *)identifier {
if ( self = [super init] ) {
cups = [[NSMutableString alloc] initWithString:identifier];
tarifa = [[NSString alloc] initWithString:identifier];
direccion = [[NSString alloc] initWithString:identifier];
nombreUsuario = [[NSString alloc] initWithString:identifier];
facturas = [[NSMutableArray alloc] init];
}
return self;
}
usuario = [[TuplaUsuario alloc] initWithString:@""];,usuario.cupsinitializes as NSMutableArray and I want it to callTuplaCups.initWithString:identifier.NS(Mutable)Arrayis not an array ofNSObject, it is an array ofid. Small but important difference.