Text and strings Storage in Objective C Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report Objective-C is an object-oriented programming language widely used to develop programs for iOS and macOS. This article focuses on discussing how text and string data can be stored in Objective-C. Types and Subtypes of Strings Objective-C has two main types of strings - NSString and NSMutableString. An NSString object is immutable and contains a sequence of Unicode characters that cannot be modified after creation. On the other hand, an NSMutableString object is mutable, which means that its contents can be modified. There are also several subtypes of NSString, each with its specific use case. These subtypes include: C Strings.NSString Literals.String Variables.1. C Strings A C string is a sequence of characters stored in a character array. In Objective-C, a C string is represented by a pointer to the first element of the character array. C strings are null-terminated, meaning that a null character (‘\0’) marks the end of the string. In this example we are going to understand the C string in Objective-C: ObjectiveC // Objective-C program to implement // C Strings #import <Foundation/Foundation.h> int main() { // Declare a character array named "myString" // and initialize it with the string "Hello, world!" char myString[] = "Hello, world!"; // Print the contents of the "myString" array to // the console using the "NSLog" function NSLog(@"%s", myString); return 0; } Output: 2. NSString Literals An NSString literal is a sequence of characters enclosed in double quotes. In Objective-C, NSString literals are represented by the @ symbol followed by the string enclosed in double quotes. In this example, we will understand the NSString literal in Objective-C. ObjectiveC // Objective-C program to implement // NSString Literals #import <Foundation/Foundation.h> int main() { // Create an NSString object named "myString1" // and initialize it with the string "Hello, world!" NSString *myString1 = @"Hello, world!"; // Print the value of "myString1" using NSLog NSLog(@"myString1: %@", myString1); // Return 0 to indicate successful completion of the program return 0; } Output: 3. String Variables A string variable is a variable that stores a string value. In Objective-C, string variables are declared using the NSString or NSMutableString class. In this example, we are going to understand string variables in Objective-C. ObjectiveC // Objective-C program to implement // string variables int main() { // Create an NSString object named "myString2" // and initialize it with the string "Hello, world!" NSString *myString2 = @"Hello, world!"; // Create an NSMutableString object named "myMutableString" // and initialize it with the string "Hello, world!" NSMutableString *myMutableString = [NSMutableString stringWithString:@"Hello, world!"]; // Print the value of "myString2" using NSLog NSLog(@"myString2: %@", myString2); // Print the value of "myMutableString" using NSLog NSLog(@"myMutableString: %@", myMutableString); // Return 0 to indicate successful completion of the program return 0; } Output: Comment More infoAdvertise with us Next Article Text and strings Storage in Objective C mukulsomukesh Follow Improve Article Tags : Objective-C Similar Reads Strings in Objective-C Strings are a fundamental concept in programming, and they are used to represent text in many different applications. In Objective-C, a string is an object that represents a sequence of characters. A string can be created using several built-in classes and methods, which allow you to manipulate the 4 min read Structures in Objective-C Objective-C is an object-oriented programming language that adds small talk-style messaging to the C programming language. Follows a bottom-up programming approach. It incorporates concepts from both procedural and object-oriented programming languages. Objective-C support structures. So in this art 5 min read Pointer to Arrays in Objective-C In Objective-C, a pointer to an array is a way to store multiple values of the same data type in contiguous memory locations. These arrays can be manipulated and accessed using pointers, which are variables that store the memory address of another variable. In Objective-C, pointers to arrays are use 4 min read Pointers in Objective-C In Objective-C, Pointers are the variables that hold the memory address of another variable. You must have declared the pointer variable before its use. The size of the pointer depends on the architecture of the system. The pointer variable can be defined as a char, int, float, double, or any other 5 min read Array of Pointers in Objective-C A pointer is a variable that stores the address of another variable. We use pointers because, with the help of pointers the memory is accessed efficiently, it saves memory space, and execution time is faster as compared to the use of normal variables using stack memory because pointers store their m 5 min read Singleton Class in Objective-C Objective-C serves as a programming language widely employed to construct applications intended for both macOS and iOS. Among the many design patterns that find extensive usage in Objective-C, the Singleton pattern proves quite noteworthy. A Singleton represents a class in that instantiation remains 6 min read Dates and Times in Objective-C In Objective-C, dates and times are represented using the NSDate and NSDateFormatter classes. NSDate class represents a single point in time. It stores an absolute point in time, independent of any particular calendar or time zone. You can use NSDate to represent a date and time, or just a date or t 4 min read Pointers to Structures in Objective C A pointer is a variable whose value is the address of another variable, e.g., stores the address of the memory location. Like any variable or constant, you must declare a pointer before you can use it to store variable addresses. It simplifies the programs and reduces their length. It is useful for 3 min read Properties in Objective-C The object-oriented programming language Objective-C is largely used to create applications for Apple's macOS and iOS platforms. It incorporates all of the characteristics of C while also providing more features for object-oriented programming, making it a superset of the C programming language. The 5 min read Variables in Objective-C A variable is a place for data storage that our programs can access or manipulate. In Objective-C, variables have a defined type that specifies their shape and layout. They also cover the gamut of values and operations that we are capable of performing. Before moving further, we understand the guide 4 min read Like