> I appologise now if this has more to do with my lack of understanding
> of singletons rather than an FMDB issue, but does my method of
> implementing with FMDB a singleton look correct?
> Shouldn't the database connection still be open as I'm not actually
> ever closing it?
> or is ARC doing something in the background which is causing it to be
> closed?
I would suggest setting a breakpoint in FMDatabase's close method. Then if it is being closed somewhere, that'll help you track down where.
-gus
--
August 'Gus' Mueller
Flying Meat Inc.
http://flyingmeat.com/
Thanks for the reply.
I've set a breakpoint as you said and it never fires.
The app runs as mentioned previously and I get the same
The FMDatabase <FMDatabase: 0x7e01e40> is not open.
message when running the
FMResultSet *rs = [self.database executeQuery:@"SELECT value FROM
config WHERE attribute = ?", attribute];
line.
I've stepped through and can see the database connection being made.
The singleton returns the instance of the DatabaseController as
expected.
Is there any other way that the database connection would be closing?
It's really got me stumped.
cheers,
Brett
> I've set a breakpoint as you said and it never fires.
> The app runs as mentioned previously and I get the same
>
> The FMDatabase <FMDatabase: 0x7e01e40> is not open.
>
> message when running the
>
> FMResultSet *rs = [self.database executeQuery:@"SELECT value FROM
> config WHERE attribute = ?", attribute];
>
> line.
>
> I've stepped through and can see the database connection being made.
> The singleton returns the instance of the DatabaseController as
> expected.
> Is there any other way that the database connection would be closing?
I suppose there might be another way, but I can't think of any off the top of my head.
I'm not sure what to suggest at this point, other then really taking a hard look at your code and putting assertions all over the place, etc. If you do find the problem and it's FMDB's fault- make sure to let me know!
I think I might have figured out whats happening. Your documentation
says "So don't instantiate a single FMDatabase object and use it
across multiple threads." which is pretty much exactly what I'm doing.
:(
I have the DatabaseController which creates the singleton (with an
instance of FMDatabase). I then spawn the WebController "sync" method
using
[NSThread detachNewThreadSelector:@selector(syncDataFromWebsite:)
toTarget:[WebController sharedInstance] withObject:nil];
When I am debugging