Reputation: 2427
I need some help in understanding the following code:
What is the meaning of '@' in @"Reload"
button = MakeTestButton(&button_rect, @"Reload", content); [button setTarget:web_view]; [button setAction:@selector(reload:)];
Where I can find the definition of "@selector(reload:)"?
Upvotes: 0
Views: 200
Reputation: 213688
@selector
is a built in primitive in the language. Think of @selector(reload:)
as “the name of the method reload:
”. It returns a SEL
, which you can then pass to a function and later use it to call the method reload:
. In the context of your code, when you click the button, the button will call [web_view reload:self]
.
In @"Reload"
, the @
means that it's an NSString
instance instead of a char const *
.
Upvotes: 4
Reputation: 713
The @ sign indicates to the compiler that the string is an NSString instead of a standard "C" string. This is a shortcut for creating NSString objects.
Upvotes: 4
Reputation: 25001
@"some text"
in objective-c. This creates an instance of NSString
.@selector(reload:)
will get a pointer to the method that will be called when an objects receives a reload:
message.Upvotes: 5