views:

198

answers:

2

Hi!

I am working on a iphone/Ipod touch project involving saving and fetching data from an sqlite database. It is working fine, but at some points in development i get this error (when the app starts):

erminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0x4e, 0x49, 0x42, 0x41, 0x72, 0x63, 0x68, 0x69)' 2009-11-09 10:08:28.810 FagNavigasjon[1627:20b]

Previously i have only been able to solve this problem by reverting to earlier point in develepment and continuing. This time i have found out that if i comment out a certain part of the code, the app doesnt crash.

while(sqlite3_step(selectstmt3)==SQLITE_ROW){
/*
   NSString *navn=[[NSString alloc] initWithUTF8String: (char *)sqlite3_column_text(selectstmt3, 0)];
   NSString *telefon=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(selectstmt3, 1)];
   NSString *fodselsar=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(selectstmt3, 2)];
   NSString *ariframtiden=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(selectstmt3, 3)];
   NSString *verneplikt=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(selectstmt3, 4)];
   NSString *utdannelse=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(selectstmt3, 5)];
  NSString *epost=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(selectstmt3, 6)];

  appDelegate.navn=navn;
  appDelegate.epost=epost;
  appDelegate.telefon=telefon;
  appDelegate.fodselsar=fodselsar;
  appDelegate.studiear=ariframtiden;
  appDelegate.utdannelse=utdannelse;
  appDelegate.verneplikt=verneplikt;
  */
 }

But of course the app doesnt load the data anymore. This code previously worked, and i have not changed it prior to this error. I have, however, added new records to the database, but these seem okay when i review them in SQLite manager. Can anyone tell me what can cause this problem? I am thankful for any responses!

+1  A: 

Have you tried uncommenting every line one by one to see which line is causing the problem? If you know which line is causing it try to see if the data in the database is correct, also if you are using version control try reverting your database back to before you added the new records.

p.s. Have you looked at Core Data? It could make your life a lot easier.

klaaspieter
Thanks for answering! I have tried uncommenting little by little, and it is caused allready by the first line: NSString *navn=[[NSString alloc] initWithUTF8String: (char *)sqlite3_column_text(selectstmt3, 0)];As I understand it the row is found in the database, but as soon as I start reading from it, i get the error...I havent checked out Core Data yet, but I will. Thanks for the advice!
Ezop
A: 

Just for the records: i have resolved this issue, though i still dont really understand how. As I knew which table caused the problem. I went in there using SQLlite manager and changed the values om some varchar fields, and the problem went away... The old values looked ok, though. Wish i could explain why this solved it...

Ezop