title: Getting error in sqlite ios NULL cString'?
body: <p>I'm building an iOS app using Storyboards.I am facing an issue in my sqlite database i'm getting the field value here </p>
  
  <pre><code>NSLog(@"selfuserid: %@",selfuserid);
  </code></pre>
  
  <p>but my code goes again to the below code.           </p>
  
  <pre><code>NSString * selfuserid =[NSString stringWithUTF8String:(const char *)sqlite3_column_text(stmt, 1)];
  </code></pre>
  
  <p>here is my code:</p>
  
  <pre><code>-(NSArray *) getRecords:(NSString*) filePath where:(NSString *)whereStmt
  {
  NSMutableArray * students =[[NSMutableArray alloc] init];
  sqlite3* db = NULL;
  sqlite3_stmt* stmt =NULL;
  int rc=0;
  rc = sqlite3_open_v2([filePath UTF8String], &amp;db, SQLITE_OPEN_READONLY , NULL);
  if (SQLITE_OK != rc)
  {
      sqlite3_close(db);
      NSLog(@"Failed to open db connection");
  }
  else
  {
      NSString  * query = @"SELECT * from students";
      if(whereStmt)
      {
          query = [query stringByAppendingFormat:@" WHERE %@",whereStmt];
      }
      rc =sqlite3_prepare_v2(db, [query UTF8String], -1, &amp;stmt, NULL);
      if(rc == SQLITE_OK)
      {
          while (sqlite3_step(stmt) == SQLITE_ROW) //get each row in loop
          {
  NString * selfuserid =[NSString stringWithUTF8String:(const char *)sqlite3_column_text(stmt, 1)];//here the code comes again
  NSString * profilepic =[NSString stringWithUTF8String:(const char *)sqlite3_column_text(stmt, 2)];
  NSString * username =[NSString stringWithUTF8String:(const char *)sqlite3_column_text(stmt, 3)];
  NSString * selectedsports =[NSString stringWithUTF8String:(const char *)sqlite3_column_text(stmt, 4)];
       NSDictionary *student =[NSDictionary dictionaryWithObjectsAndKeys:selfuserid,@"selfuserid",profilepic,@"profilepic",username,@"username",selectedsports,@"selectedsports", nil];
  [students addObject:student];
  NSLog(@"selfuserid: %@",selfuserid);i'm getting selfuserid here but code goes again to the above stm
  NSLog(@"pic: %@",profilepic);
  }
  NSLog(@"Done");
  sqlite3_finalize(stmt);
  }
  else
  {
  NSLog(@"Failed to prepare statement with rc:%d",rc);
  }
  sqlite3_close(db);
  }
  return students;
  }
  </code></pre>
  
  <p>I'm getting this exception:</p>
  
  <pre><code> Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSString stringWithUTF8String:]: NULL cString'
  
      *** First throw call stack:
      (
      0   CoreFoundation                      0x000000010450ef35 __exceptionPreprocess + 165
      1   libobjc.A.dylib                     0x00000001041a7bb7 objc_exception_throw + 45
      2   CoreFoundation                      0x000000010450ee6d +[NSException raise:format:] + 205
      3   Foundation                          0x0000000103d0c464 +[NSString stringWithUTF8String:] + 78
      4   Playo                               0x0000000101a038f9 -[Play getRecords:where:] + 617
      5   Playo                               0x0000000101a06697 -[Play tableView:didSelectRowAtIndexPath:] + 231
      6   UIKit                               0x0000000104c26393 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1293
      7   UIKit                               0x0000000104c264d4 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
      8   UIKit                               0x0000000104b61331 _applyBlockToCFArrayCopiedToStack + 314
      9   UIKit                               0x0000000104b611ab _afterCACommitHandler + 516
      10  CoreFoundation                      0x0000000104443dc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
      11  CoreFoundation                      0x0000000104443d20 __CFRunLoopDoObservers + 368
      12  CoreFoundation                      0x0000000104439b53 __CFRunLoopRun + 1123
      13  CoreFoundation                      0x0000000104439486 CFRunLoopRunSpecific + 470
      14  GraphicsServices                    0x00000001063299f0 GSEventRunModal + 161
      15  UIKit                               0x0000000104b3e420 UIApplicationMain + 1282
      16  Playo                               0x0000000101a34813 main + 115
      17  libdyld.dylib                       0x0000000105f47145 start + 1
     )
     libc++abi.dylib: terminating with uncaught exception of type NSException
  </code></pre>