首页 > 其他 > 详细

FirstDay

时间:2014-02-09 23:59:40      阅读:658      评论:0      收藏:0      [点我收藏+]

废话少说,直接正题。

  今天使用VMware安装OS X 7.0、Xcode 4.2.1开始第一个Objective-C的程序,也就是HelloWorld。以下是从网上copy的代码

bubuko.com,布布扣
1 #import<Foundation/Foundation.h>  
2 int main (int argc, constchar * argv[])  
3 {  
4     NSAutoreleasePool * pool = [[NSAutoreleasePoolalloc] init];
5     NSLog(@"Hello,iphone!");
6     [pool drain];
7     return 0;  
8 }  
bubuko.com,布布扣

但把代码敲进去的时候,编译是失败的,查阅资料得知:

Xcode4.2之后就不使用NSAutoreleasePool这种东西了,改用了@autoreleasepool{...}这种玩意.

查阅的源地址

原文copy如下:

Whenever a new Xcode release and iOs version comes out, there is a lot of new adjustments to make. Apple make a lot of change that are a real pain at the start, but generally make sense after a while.

With Xcode 5, apple have added ARC (automatic reference counting) when you compile the application. This breaks a lot of the old way of doing things, such as release, autorelease, and using NSAutoreleasePool.

So if we have code such as this:

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
…..
[pool release];

We will get an error. But all we need to do is change the format of the code to this:

@autoreleasepool {
….
}

Or you can switch of ARC by setting CLANG_ENABLE_OBJC_ARC to NO in the Build Settings of your app.bubuko.com,布布扣

You can read more about ARC herehttps://developer.apple.com/library/ios/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html

 

至此搞定第一个程序,改天再接再厉。

 

一些可预见的计划:

1. 学习Objective-C基础语法

2. 学习iOS开发基础

FirstDay

原文:http://www.cnblogs.com/insIs0n/p/3541981.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!