gpt4 book ai didi

ios - 如何使用 NSNotificationCenter 调用第二类中的方法?

转载 作者:行者123 更新时间:2023-11-28 22:36:30 26 4
gpt4 key购买 nike

我正在尝试使用 NSNotificationCenter 调用第二个类中的方法,但出现错误:

第二类方法(request.m):

-(void)getTheRequest:(NSString *)whereToCall;

我正在尝试从 NSNotificationCenter 调用它,如下所示:

request *newRequest=[[request alloc]init];
[self performSelector:@selector(newRequest.getTheRequest:) withObject:@"mySite"];

但是我在这部分“newRequest.getTheRequest”中遇到了一个错误,它说“Expected Expression”。你们知道我该如何解决这个问题或者我如何使用 NSNotificationCenter 调用不同类中的方法吗?

最佳答案

试试这个:

[newRequest performSelector:@selector(getTheRequest:) withObject:@"mySite"];

请注意,类名应以大写字母开头,getter 不应使用 Apple 编码标准的 get 前缀 Introduction to Coding Guidelines for Cocoa

关于ios - 如何使用 NSNotificationCenter 调用第二类中的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15828820/

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