Become a MacRumors Supporter for $25/year with no ads, private forums, and more!

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];
 
Comment

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,003
4,869
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?
 
Comment

dantastic

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

try

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

instead
 
Comment

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.
 
Comment

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: 69
Comment
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.