2011年4月21日木曜日

Objective-CとC++の機能の混在

http://developer.apple.com/jp/documentation/cocoa/conceptual/objectivec/Articles/chapter_12_section_3.html

class Hello {
    private:
        id _greeting_text;  // NSStringを保持
    public:
        Hello() {
            _greeting_text = @"Hello, world!";
        }
        Hello(const char* greeting_text) {
            _greeting_text = [NSString stringWithUTF8String:greeting_text];
        }
        void say_hello() {
            printf("%s\n", [_greeting_text UTF8String]);
        }
};
 
@interface Greeting :NSObject {
    @private
        Hello *_hello;
}
- (id)init;
- (void)dealloc;
- (void)sayGreeting;
- (void)sayGreeting:(Hello*)greeting;
@end

0 件のコメント:

コメントを投稿