Screen Shot 2016-07-17 at 11.02.35 PM

[Obj-c]AppKitを読み込んでコマンドラインでコンパイルする

[Obj-c]AppKitを読み込んでコマンドラインでコンパイルするmain.m

#import "ImitationClass.h"

int main(int argc, char **argv, char** envp) {
	ImitationClass *imitationClass = [[ImitationClass alloc] init];

	[imitationClass instansMethod];

	[imitationClass dealloc];

    return 0;
}

ImitationClass.h

#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import <stdio.h>

@interface ImitationClass : NSObject

- (void)instansMethod;


@end

ImitationClass.m

#import "ImitationClass.h"

@implementation ImitationClass

- (void)instansMethod{
	NSSpeechSynthesizer *speechSynth = [[NSSpeechSynthesizer alloc] init];
	[speechSynth setVoice:@"com.apple.speech.synthesis.voice.kyoko"];
	[speechSynth setRate:240];
	[speechSynth setVolume:1.9];
	[speechSynth startSpeakingString:@"おっす!おらっごっくうぅ"];
	sleep(1);
	while([speechSynth isSpeaking]);
	
}

@end
gcc main.m ImitationClass.m -framework Foundation -framework AppKit
./a.out

参考サイトさま:

About the author
  • コメントを残す