Escape single quotes in strings for SQLite3 database

This is a Objective-C snippet, talking about NSString, escape, sqlite and database

Escape single quotes in strings for SQLite3 database Add to Favorite

+ (NSString *) escapeString:(NSString *)string {
	NSRange range = NSMakeRange(0, [string length]);
	return [string stringByReplacingOccurrencesOfString:@"'" withString:@"''" options:NSCaseInsensitiveSearch range:range];
}

This function will escape the NSString for SQLite3 database. You can use this function to escape or change any other character.

Created by ThePeppersStudio (1715 days, 20.46 hours ago)

Do you want to leave a message? Please login first.