gpt4 book ai didi

objective-c - 什么是 Objective-C 中的接收器?

转载 作者:行者123 更新时间:2023-12-01 11:17:57 25 4
gpt4 key购买 nike

我对 Objective-C 中的“接收器”是什么感到困惑?

在以下站点上,关于接收器的内容如下:https://quizlet.com/104540068/objective-c-flash-cards/

"In Objective-C, you specify the object (known as the receiver of the method) and the message being sent to that object by enclosing the message expression in brackets."



我不明白这个。我对 Objective-C 很陌生。感谢任何帮助。谢谢。

最佳答案

在 Objective-C 中,消息被发送到接收者。

消息是您正在调用的方法。接收者是消息被调用的对象。

例子。假设您有一个 NSString :

NSString *str = @"Hello";

现在你想得到字符串的长度。您发送 length留言给 str . str是消息的接收者:
NSInteger len = [str length];

基本上,接收方是方括号内左侧的部分,消息是方括号中右侧的部分。

关于objective-c - 什么是 Objective-C 中的接收器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48246472/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com