I have a class that manages my entire database, my project is in Swift but I have two classes in Objective-C to bridge the classes and my Helper .
p>After some testing on the iOS simulator I had the following error message:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** + [NSString stringWithUTF8String:]: NULL cString '
Why did this happen?
Follow my two classes:
SQLiteObjc.h
:
#import <Foundation/Foundation.h>
#import "sqlite3.h"
@interface SQLiteObjc : NSObject
+ (void) bindText:(sqlite3_stmt *)stmt idx:(int)idx withString: (NSString*)s;
+ (NSString*) getText:(sqlite3_stmt *)stmt idx:(int)idx;
@end
SQLiteObjc.m
:
#import "SQLiteObjc.h"
@implementation SQLiteObjc
+ (void) bindText:(sqlite3_stmt *)stmt idx:(int)idx withString: (NSString*)s {
sqlite3_bind_text(stmt, idx, [s UTF8String], -1, nil);
}
+ (NSString*) getText:(sqlite3_stmt *)stmt idx:(int)idx {
char *s = (char *) sqlite3_column_text(stmt, idx);
NSString *string = [NSString stringWithUTF8String:s];
return string;
}
@end