Search Results

Search found 7 results on 1 pages for 'fmdb'.

Page 1/1 | 1 

  • FMDB transaction

    - by user142764
    Hi ! I use FMDB to wrap SQLite in my app. I haven't found any docs about the use of methods begin, beginUpdates, commit, finalize, etc. I face some problems in my apps which i think are caused by the way i use transactions. Here is what i tried : [FMDB beginUpdates] - My insert statement - [FMDB commit] [FMDB finalize] it crashes with this log : Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[FMDatabase<0xd705a0 finalize]: called when collecting not enabled' Could you please give me an example of how you are using transactions, or point me to a doc ? Thanks in advance, Vincent.

    Read the article

  • compiler directive defensive programming for adding ints to nsmuatablearray FMDB/EGODB

    - by johndpope
    I would like to throw a warning message when users try to add an int to an nsmutablearray basically any insert statement that includes values that are not nsstring / nsnumber cause run time crashes. It's exactly the same crash you get when you type %@ instead of %d NSLog(int); The crash is ok, but I want to throw a friendly 'FATAL' message to user. so far I have this try catch with isKindOfClass NSObject but ints are slipping through. #define FATAL_MSG "FATAL: object is not an NSObject subclass. Are you using int? use [NSNumber numberWithInt:1] \n" #define VAToArray(firstarg) ({\ NSMutableArray* valistArray = [NSMutableArray array];\ id obj = nil;\ va_list arguments;\ va_start(arguments, sql);\ @try { \ while ((obj = va_arg(arguments, id))) {\ if([obj isKindOfClass:[NSObject class]]) [valistArray addObject:obj];\ else printf(FATAL_MSG); \ }\ } \ @catch(NSException *exception){ \ printf(FATAL_MSG); \ } \ va_end(arguments);\ valistArray;\ }) - (void)test:(NSString*)sql,... { NSLog(@"VAToArray :%@",VAToArray(sql)); } // then call this [self test:@"str",@"test",nil]; when I call this [self test:@"str",2,nil]; throw the error message.

    Read the article

  • Don't know how to encrypt database using SQLCipher

    - by Armaan
    I have included SQLCipher into my project exactly like explained in this link: http://sqlcipher.net/ios-tutorial/ But I am not sure how to encrypt the database I have read description from above link but not getting. Actually what I am doing is if application is opening first time then it will copy the database(i.e. without encryption) to the document directory. One more thing my database is blank when copying from bundle to document directory. I have tried to use sqlite3_key function after opening the database but nothing is encrypted. But I didn't found something like how to encrypt database when copying from bundle to document directory. I am planning to use FMDB so it would be better to reply according to that. Please guide me how to do that or point to direction if is there any tutorial for it. Also suggest what should be the standard approach to do that.

    Read the article

  • SQLite on iPhone - Techniques for tracking down multithreading-related bugs

    - by Jasarien
    Hey guys, I'm working with an Objective-C wrapper around SQLite that I didn't write, and documentation is sparse... It's not FMDB. The people writing this wrapper weren't aware of FMDB when writing this code. It seems that the code is suffering from a bug where database connections are being accessed from multiple threads -- which according to the SQLite documentation won't work if the if SQLite is compiled with SQLITE_THREADSAFE 2. I have tested the libsqlite3.dylib provided as part of the iPhone SDK and seen that it is compiled in this manner, using the sqlite_threadsafe() routine. Using the provided sqlite library, the code regularly hits SQLITE_BUSY and SQLITE_LOCKED return codes when performing routines. To combat this, I added some code to wait a couple of milliseconds and try again, with a maximum retry count of 50. The code didn't contain any retry logic prior to this. Now when a sqlite call returns SQLITE_BUSY or SQLITE_LOCKED, the retry loop is invoked and the retry returns SQLITE_MISUSE. Not good. Grasping at straws, I replaced the provided sqlite library with a version compiled by myself setting SQLITE_THREADSAFE to 1 - which according to the documentation means sqlite is safe to be used in a multithreaded environment, effectively serialising all of the operations. It incurs a performance hit, that which I haven't measured, but it ridded the app of the SQLITE_MISUSE happening and seemed to not need the retry logic as it never hit a busy or locked state. What I would rather do is fix the problem of accessing a single db connection from multiple threads, but I can't for the life of me find where it's occurring. So if anyone has any tips on locating multithreaded bugs I would be extremely appreciative. Thanks in advance.

    Read the article

  • Will pool the connection help threading in sqlite (and how)?

    - by mamcx
    I currently use a singleton to acces my database (see related question) but now when try to add some background processing everything fall apart. I read the sqlite docs and found that sqlite could work thread-safe, but each thread must have their own db connection. I try using egodatabase that promise a sqlite wrapper with thread safety but is very buggy, so I return to my old FMDB library I start to see how use it in multi-thread way. Because I have all code with the idea of singleton, change everything will be expensive (and a lot of open/close connections could become slow), so I wonder if, as the sqlite docs hint, build a pooling for each connection will help. If is the case, how make it? How know wich connection get from the pool (because 2 threads can't share the connection)? I wonder if somebody already use sqlite in multu-threading with NSOperation or similar stuff, my searching only return "yeah, its possible" but let the details to my imagination...

    Read the article

  • Need some advice before starting coding my next iPhone app...

    - by Tom
    Hi! I need some advice about how should I start coding something. So here is the context: I've just finished building a CMS that manage a SQLite database. My application will be picking this database and use its content as the application's content. So far it's pretty simple. The application will have a navigation that will browse through various workflows, and once at the end workflow, it'll show contents from the database. A consultation kind a thing, example: Liquids - Juice - Orange Juice - Informations about Orange Juice. For my SQLite transactions, so far I believe I'll be using fmdb. It looks like a great wrapper. Here's a simple schema from one of the database: Workflow: id: { type: integer(3), primary: true, autoincrement: true } workflow_id: { type: integer(1) } name: { type: string(255) } That table's rows will be my navigations. Do you believe I should use a navigation controller? If so, then how could I generate the navigation tree from it? I have a good working knowledge of Objective-C and Foundation framework, but never went too far with it so that is why I'm asking before starting in the wrong direction :) Thanks a lot.

    Read the article

  • Slow loading of UITableView. How know why?

    - by mamcx
    I have a UITableView that show a long list of data. Use sections and follow the sugestion of http://stackoverflow.com/questions/695814/how-solve-slow-scrolling-in-uitableview . The flow is load a main UITableView & push a second selecting a row from there. However, with 3000 items take 11 seconds to show. I suspect first from the load of the records from sqlite (I preload the first 200). So I cut it to only 50. However, no matter if I preload only 1 or 500, the time is the same. The view is made from IB and all is opaque. I run out of ideas in how detect the problem. I run the Instruments tool but not know what to look. Also, when the user select a cell from the previous UITable, no visual feedback is show (ie: the cell not turn selected) for a while so he thinks he not select it and try several times. Is related to this problem. What to do? NOTE: The problem is only in the actual device: iPod Touch 2d generation Using fmdb as sqlite api Doing the caching in viewDidLoad Using NSDictionary for the caching Using a NSAutoreleasePool for the caching part. Only caching the row ID & mac 4 fields necesary to show the cell data UIView made with interface builder, SDK 2.2.1 Instruments say I use 2.5 MB in the device

    Read the article

1