gpt4 book ai didi

objective-c - cocoa 中的私有(private)方法?

转载 作者:行者123 更新时间:2023-12-03 17:43:42 25 4
gpt4 key购买 nike

Possible Duplicate:
Best way to define private methods for a class in Objective-C

嗨,我可以为 cocoa 应用程序中的任何类拥有私有(private)方法吗?如果是,怎么办?

最佳答案

是的,你可以!

在您的 *.m 文件中(实现)

#import "MyClass.h"

@interface MyClass()
- (void)privateMethod();
@end

@implementation MyClass

- (void)dealloc {
[super dealloc];
}

- (void)privateMethod
{
NSlog(@"myPrivateMethod");
}
@end

关于objective-c - cocoa 中的私有(private)方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5091821/

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