#import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { NSString *sql_stmt = @"CREATE TABLE IF NOT EXISTS EMPLOYEES ("; sql_stmt = [sql_stmt stringByAppendingString:@"id INTEGER PRIMARY KEY AUTOINCREMENT, "]; sql_stmt = [sql_stmt stringByAppendingString:@"name TEXT, "]; sql_stmt = [sql_stmt stringByAppendingString:@"department TEXT, "]; sql_stmt = [sql_stmt stringByAppendingString:@"age TEXT)"]; NSLog(@"%@",sql_stmt); NSMutableString *sql_stmt2 = [[NSMutableString alloc] initWithString:@"CREATE TABLE IF NOT EXISTS EMPLOYEES ("]; [sql_stmt2 appendString:@"id INTEGER PRIMARY KEY AUTOINCREMENT, "]; [sql_stmt2 appendString:@"name TEXT, "]; [sql_stmt2 appendString:@"department TEXT, "]; [sql_stmt2 appendString:@"age TEXT)"]; NSLog(@"%@",sql_stmt2); } return 0; }
All one can think and do in a short time is to think what one already knows and to do as one has always done!
Site Information ...
▼
Objective C String concatenation example
Well in any programming language this is considered one of important string manipulation functions and as simple as adding a plus sign between the two strings. Guess what its not that easy in Objective C, here is how to achieve string concatenation when using either NSString or NSMutableString classes.
No comments:
Post a Comment
NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.