0

例如,Objective-C 可以调用一个调用 Objective-C 的 C 函数吗?

(UIColor *) getUIColorWithRGB(int r, int g, int b) {
    return [UIColor colorWithRed: r / 255.0 green: g / 255.0 blue: b / 255.0 alpha: 1];
}

@implementation UIColorCollection

+(UIColor *) lightCyanColor {
    return getUIColorWithRGB(224, 255, 255);
}
4

1 回答 1

1

如果谈论可能性,它是可能的。只需去掉 C 函数返回值中的括号即可:

UIColor * getUIColorWithRGB(int r, int g, int b) {
    return [UIColor colorWithRed: r / 255.0 green: g / 255.0 blue: b / 255.0 alpha: 1];
}

不过,不确定这是否可以作为编程实践。

于 2012-06-01T10:52:05.417 回答