函数调用-Objective C
Function calling -Objective C
本文关键字:-Objective 函数调用 更新时间:2023-10-16
我是Objective-C的新手。我正在将c++代码移植到Objective-C中。我有这个函数调用eventLog()
insamples.cpp
和我已经申报了功能在samples.h
。我有它对EventLog.cpp
的定义包括samples.h
头文件
samples.h
class samples
{
declaration;
}
samples.cpp
#include "samples.h"
void samples::buttonClick()
{
eventLog();
}
EventLog.h
#include "samples.h"
EventLog.cpp
void samples::eventLog()
{
//definition;
}
在Objective-C中是等价的吗?
samples.h
- (void)eventLog;
samples.m
samples* a = [[samples alloc]init];
[a eventLog];
EventLog.h
#import "samples.h"
EventLog.m
-(void)eventLog
{
//Definition;
}
看起来不错,除了你在做你的
#import <Foundation/Foundation.h>
@interface EventLog : NSObject {
}
- (void)eventLog;
@end
和
#import "EventLog.h"
#import "Samples.h"
@implementation EventLog
- (void)eventLog
{
//definition
}
@end
?如果没有适当的类"包装器",就必然会遇到问题。还有,你的文件很乱。如果samples.h
实现了eventLog
,你就不应该在EventLog.m
中实现它。这将是samples.m
的工作。
不,这是错误的…
创建一个EventLog实例。样本中的M。M,使用以下行:
EventLog *obj = [[EventLog alloc] init];
Then, use [EventLog eventLog];
相关文章:
- 函数调用中参数的顺序重要吗
- 基于另一个成员参数将函数调用从类传递给它的一个成员
- 变量没有改变?通过向量的函数调用
- 在两个类中共享相同的函数调用,并在不需要时避免空实例化
- 是否有C++编译器选项允许激进地删除所有函数调用,并将参数传递给具有空体的函数
- 我知道函数调用中存在歧义.有没有办法调用foo()函数
- 模板函数调用
- 获取从C++中同一类中的构造函数调用的方法返回的值
- 析构函数调用
- 成员函数调用和C++对象模型
- 使用共享指针的函数调用,其对象应为 const
- C++:编译时检查匹配的函数调用对?
- 函数调用C++中的参数太少
- 来自 DLL 的函数调用 [表观调用的括号前面的表达式必须具有(指向-)函数类型]
- 返回指向对象的指针的函数调用是否为 prvalue?
- C++ 如何重载 [] 运算符并进行函数调用
- 代码的效率. 转到和函数调用
- 是同一作用域的函数部分中的函数调用
- 从 Objective-C 函数调用C++函数不起作用
- 函数调用-Objective C