@ "% @ in Objective-C?

I followed tut and found a line of code like @"%@ button pressed.". I'm sure that the corresponding part is% @, but the first @ is the escape sequence, or what?

In any case, the search for characters does not go well on any search engine, so I thought I would ask. I think% @ is like {0} in C #?

+3
source share
4 answers

%@- format specifier. Functions such as NSLogmethods, such as +stringWithFormat:, will be replaced by a %@description of the supplied argument of the Objective-C object or the main object.

For instance:

NSString *myName = @"dreamlax";

NSLog (@"My name is: %@", myName);

This will result in logging output "My name is: dreamlax". See here for more detailed format specifications.

@ NSString. @ C. C- Objective-C, NSArray NSDictionary ..

+9

@ " " , NSString.

, @ "CupOverflowException", NSString. @ Objective-C . C C ++, "String " char *

+2

, : @, / NSObject .

, :

@ "SOMETEXT"

NSString someText. C, :

... " - , float:% f", myFloat);

- , myFloat . % @- , % f,% d,% c,% s , . , % @ :

... " , :% @", myObject];

What you do (I believe) tells the compiler that myObject is an object and that you want it to include the output of the description method (that is, [description of myObject]) in the line, Creation.

0
source

Source: https://habr.com/ru/post/1740257/


All Articles