在Windows上编写Object C程序
来源:互联网 发布:淘宝管控记录 编辑:程序博客网 时间:2024/04/28 03:16
随着iphone的流行,越来越多的程序员开始学习Object C编程,但一般来说编写Object C需要iMac计算机。这对于刚开始学习Object C编程的程序员是个问题。
本文给出了一个在 windows 平台上学习Object C编程的方法。
1.下载GNUStep
http://ftpmain.gnustep.org/pub/gnustep/binaries/windows/
下载
gnustep-msys-system-x.x.x-setup.exe
gnustep-core-x.x.x-setup.exe
gnustep-cairo-x.x.x-setup.exe
gnustep-devel-x.x.x-setup.exe
将下载的GNUStep安装,比如C:\GNUStep
2. 下载JEdit
http://www.jedit.org/index.php?page=download
JEdit 是Freeware,可以用来编辑 .m 文件 .m 是Object C缺省后缀。 .m 相当于 .c 文件
3. 一个Object C教材
http://www.otierney.net/objective-c.html
---------------------------------------------
4. 安装后,执行msys.bat 启动 GNUStep 环境 (类Linux环境)
5. 编写示例程序
fraction.h
#import <Foundation/NSObject.h> @interface Fraction: NSObject { int numerator; int denominator; } -(void) print; -(void) setNumerator: (int) n; -(void) setDenominator: (int) d; -(int) numerator; -(int) denominator; @end
fraction.m
#import "fraction.h" #import @implementation Fraction -(void) print { printf( "%i/%i", numerator, denominator ); } -(void) setNumerator: (int) n { numerator = n; } -(void) setDenominator: (int) d { denominator = d; } -(int) denominator { return denominator; } -(int) numerator { return numerator; } @end
main.m
#import #import "fraction.h" int main( int argc, const char *argv[] ) { // create a new instance Fraction *frac = [[Fraction alloc] init]; // set the values [frac setNumerator: 1]; [frac setDenominator: 3]; // print it printf( "The fraction is: " ); [frac print]; printf( "\n" ); // free memory [frac release]; return 0; }
6. 编写Makefile
在当前目录下创建GNUmakefile
include $(GNUSTEP_MAKEFILES)/common.make TOOL_NAME = Hello Hello_OBJC_FILES = main.m fraction.m include $(GNUSTEP_MAKEFILES)/tool.make
6. 编译程序
$ make
将创建 obj目录 运行 hello.exe
The fraction is: 1/3
这样环境就搭好了,你就可以继续学习 Object C了
最终写iphone程序一般还是要Mac OS.
- 在Windows上编写Object C程序
- 在Windows上学习Object-C
- Windows下使用GNUstep编写Object-C程序
- Windows平台使用NDK编写在Android上运行的C/C++标准程序
- 学习Object-C,GUNstep安装在windows上
- hadoop2.x入门:在windows上用Eclipse编写程序
- 用C语言在NDS上编写程序
- 在C语言上如何编写并运行MPI程序
- 在Android上运行C语言编写的可执行程序
- 用C语言在NDS上编写程序
- 在Android上运行C语言编写的可执行程序
- Eclipse在Windows下编写C语言的HelloWorld程序
- 在Windows平台上使用GCC编译C程序
- 在ubuntu上搭建object c
- 在windows下编译object-c语言
- Object-C在windows下的编程
- 在WINDOWS下编写小撸路由上的第一个程序
- 使用VisualGDB在windows上编写linux程序(centos)遇到的问题
- VS2010转VS2008和VS2005方法
- CentOS6.2卸载系统自带 openjdk安装sun jdk
- 由于添加外部jar包造成无法运行的问题
- 使用UIButton打开网页谷歌地图
- onCreateOptionsMenu()用法
- 在Windows上编写Object C程序
- Java String类总结
- 盘点
- 插入排序实例及Java实现
- 获取 UITableViewCell 位置
- 圖像細化(骨架化)算法 分析
- Hadoop学习笔记(一)HBase脚本分析(二)hbase-daemon.sh
- Android ProgressBar 史上最强大讲解
- 搭建小型搜索引擎---原理及工具