Learn Objective-C on Ubuntu
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://speedooo.blog.51cto.com/226772/74919 |
Objective-C is used primarily on Mac OSX and GNUStep. If you want to learn it without Mac, you can install GNUStep on Ubuntu. make sure/test GNUStep installed on your Ubuntu(8.04). add script to your .bashrc file #set GNUstep GNUSTEP_ROOT=/usr/share/GNUstep export GNUSTEP_ROOT source /usr/share/GNUstep/Makefiles/GNUstep.sh Try your first Objective-C code, >mkdir test create source code called source.m under test dir#include <stdio.h> /* * The next #include line is generally present in all Objective-C * source files that use GNUstep. The Foundation.h header file * includes all the other standard header files you need. */ #include <Foundation/Foundation.h> /* * Declare the Test class that implements the class method (classStringValue). */ @interface Test + (const char *) classStringValue; @end /* * Define the Test class and the class method (classStringValue). */ @implementation Test + (const char *) classStringValue; { return "This is the string value of the Test class"; } @end /* * The main() function: pass a message to the Test class * and print the returned string. */ int main(void) { printf("%s\n", [Test classStringValue]); return 0; } create filename GNUmakefile with code like include $(GNUSTEP_MAKEFILES)/common.make TOOL_NAME = LogTest LogTest_OBJC_FILES = source.m include $(GNUSTEP_MAKEFILES)/tool.make compile with type command make run the program with command ./obj/LogTest got message: "This is the string value of the Test class" 本文出自 “我爱我家” 博客,请务必保留此出处http://speedooo.blog.51cto.com/226772/74919 本文出自 51CTO.COM技术博客 |


speedooo
博客统计信息
热门文章
最新评论
友情链接