DavidNg
DavidNg

Reputation: 2836

iOS: releasing NSString Object, that reads data from sqlite database

I have an app that reads from sqlite database, and then shows the content in a button after each clicking the button.

 NSString *data;    
 query = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE ID=%d",TABLENAME,tempIndex];
 sqlite3_prepare_v2(contactDB,[query UTF8String],-1,&statement,NULL);
 sqlite3_step(statement);
 data = [[NSString alloc] initWithUTF8String:(const char *)sqlite3_column_text(statement, 2)];
 sqlite3_finalize(statement);
 [myButton setTitle:data forState:UIControlStateNormal];
 [data release];

However, the data never shows in the button and there is an error saying:

Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: _CFXMLNodeGetInfoPtr

If I do not release data, the app runs OK

Upvotes: 0

Views: 80

Answers (1)

Carl Veazey
Carl Veazey

Reputation: 18363

That is very strange behavior and I'd love to get to the bottom of it. But for now, autorelease your data string.

 data = [[[NSString alloc] initWithUTF8String:(const char *)sqlite3_column_text(statement, 2)] autorelease]

Upvotes: 1

Related Questions