Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-16-2010, 04:28 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 60
racharambola5 is on a distinguished road
Default NSInvalidArgumentException..NULLcString Error

Hi,
I am displaying the contacts on the table. Section I pass in the method is name of section i.e. A-Z.. and the index is the index of the row in that particular section. So to get the id based on the row I tapped in particular section,I wrote the following method. I am trying to get the id from the database whose values match with the query I pass. So if I check for the firstnames starting with letter 'A' there are around 4 values under section A. So I took a variable i and trying to increment until it finds the correct index such that it returns the id for that particular index. The condition validates but I always get the nil string and hence the values displayed on the table for each field are empty.

Please help me..Its very urgent and I am clueless on what to do..Thanks for the help!!!





Here is the method:

-(NSString *)getSugarIdNSString *)tableName bySectionNSString *)section andIndexint)index
{
int i=0;
NSString *sid;
NSString *qsql = [[NSString stringWithFormat: @"SELECT sugar_id FROM CONTACTS WHERE first_name LIKE '%@",section] stringByAppendingString:@"%'"];
sqlite3_stmt *statement;
if (sqlite3_prepare_v2( db, [qsql UTF8String], -1, &statement, nil) == SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) {
char * utf8string = (char *)sqlite3_column_text(statement, 1);
if(i==index){
sid = utf8string ? [[NSString alloc ]initWithUTF8String:utf8string] : nil;
// sid = [[NSString alloc]initWithUTF8Stringchar *)sqlite3_column_text(statement, 1)];
break;
}

i++;
}
}
return sid;
}

Last edited by racharambola5; 08-16-2010 at 06:36 PM. Reason: Changed my method implementation
racharambola5 is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, sqlite, uitableview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 355
4 members and 351 guests
givensur, linkmx, Newbie123, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,894
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:49 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0