Home > DeveloperSection > Interviews > What does the @ symbol represent in objective-c.

Posted on    August-02-2015 11:53 PM

 iPhone iPhone  Ios  Objective C 
 1 Answer(s)
  397  View(s)
Rate this:

Tarun Kumar

Total Post:107

Posted on    August-02-2015 11:53 PM

Objective-C frameworks typically do not use C-style strings. Instead, they pass strings around as NSString objects.

The NSString class provides an object wrapper for strings that has all of the advantages you would expect, including built-in memory management for storing arbitrary-length strings, support for Unicode, printf-style formatting utilities, and more. Because such strings are used commonly though, Objective-C provides a shorthand notation for creating NSString objects from constant values. To use this shorthand, all you have to do is precede a normal, double-quoted string with the @ symbol, as shown in the following examples:

NSString *myString = @"My String\n";

NSString *anotherString = [NSString stringWithFormat:@"%d %@", 1, @"String"];

Don't want to miss updates? Please click the below button!

Follow MindStick