iOS WHERE TO INIT a CLASS

joak

macrumors newbie
Original poster
Mar 7, 2014
27
0
Hello

I have one generic class to work with Database(sqlite), this class has some methods to create tables, open database, insert records, delete records etc .... if I import this class to work with other(class B), where I have to init Database class to work with his methods in all methods of class B ?
 

joak

macrumors newbie
Original poster
Mar 7, 2014
27
0
ClassB.h
Code:
@ property (strong,nonatomic) NSObject *basedatos;
ClassB.m
Code:
- (id) init
{
    self = [super init];
    if (self)
    {
        self.basedatos = [[JFBaseDatos alloc] init];
    }
    return self;
}
how can I call in another classB's metods the class basedatos?
Code:
[self.basedatos dropTables:self.arrayTableNames];
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
8,565
3,978
ClassB.h
Code:
@ property (strong,nonatomic) NSObject *basedatos;
ClassB.m
Code:
- (id) init
{
    self = [super init];
    if (self)
    {
        self.basedatos = [[JFBaseDatos alloc] init];
    }
    return self;
}
how can I call in another classB's metods the class basedatos?
Code:
[self.basedatos dropTables:self.arrayTableNames];
That all looks fine to me. What's not working? How should it work and what's it doing instead?
 

dantastic

macrumors 6502a
Jan 21, 2011
567
645
The compiler will give out about that.
dropTables: is not a method belonging to NSObject.

try

Code:
@property (nonatomic, strong) JFBaseDatos *baseDatos;
instead
 

joak

macrumors newbie
Original poster
Mar 7, 2014
27
0
Dantastic ... I asked how it's correct to instance an object because when I have used the methods of JFBaseDatos some works bad.

The class JFBaseDatos, has a method to create tables, the database file it's created and I can review the structure all tables and it's fine ... but, when I want to insert records, I can't because I have gotten a message that a "id_torneo" column dosen't exist ... but yes..... it's exists .. I can see it in the database file.