Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

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
9,462
5,888
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
572
678
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.
 

joak

macrumors newbie
Original poster
Mar 7, 2014
27
0
I found the error, the syntax create table it's bad.
 

Attachments

  • Captura de pantalla 2014-03-20 a la(s) 09.17.55.png
    Captura de pantalla 2014-03-20 a la(s) 09.17.55.png
    65.6 KB · Views: 81
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.