跳到主要內容

[Tutorial] Xcode Hello World OSX


Step 1: Open a Xcode, select Create a new Xcode project (See fig 1) and click open button.
Figure 1


Now select ViewBase application and click next (See figure 2)
Figure 2



Next page you need to define Product name and Identifier name, the identifier is the name of your application. It’s the same name used when you register your application at Apple’s website and release it to the AppStore. The Product name “HelloWorld Xcode4” and the Identifier name “com.mycompany.APPLICATIONNAME” (See figure 3). Select the Device Family into iPhone. Now select next and save the application in your disk.
Figure 3


Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory (See the figure 4).
Figure 4


Step 3: Expand classes and notice Interface Builder created the HelloWorld_Xcode4ViewController class for you and generated a separate nib, HelloWorld_Xcode4ViewController.xib, for the “HelloWorld_Xcode4”.
Step 4: Select the HelloWorld_Xcode4ViewController.h file from the Project Navigator. We have added UILabel for display the text and added IBAction buttonPressed; in the file, so make the following changes in the file.
#import <UIKit/UIKit.h>
@interface HelloWorld_Xcode4ViewController : UIViewController {

    IBOutlet UILabel *label;
     
}
@property (nonatomic, retain) IBOutlet UILabel *label;
-(IBAction)buttonPressed;
@end
Step 5: Double click the HelloWorld_Xcode4ViewController.xib file from Project Navigator. Now the .xib window will look like (figure 5).
Figure 5


a) Now drag the label and RoundRect button from the object (See figure 6).
Figure 6


b) Select Label from the Window and change the label Text name from the Attribute Inspector (See figure 7). Give the Text name “Hello World!!!”.
Figure 7


c) Next select the RoundRect Button from the window and select Attribute Inspector (See figure 8). Give the Title “Click Me”.
Figure 8


d) Now connect File’s Owner icon to the “Hello World!!!” label and select label (See figure 9).
Figure 9


e) Select “Click Me” button and bring up Connection Inspector (See figure 10) and connect Touch up Inside to the File’s Owner icon and select buttonPressed: method.
Figure 10


f) Select File’s Owner icon to the View window and select view (See figure 11).
Figure 11


Now save it and open the HelloWorld_Xcode4ViewController.m file from the Project Navigator.
Step 6: In the HelloWorld_Xcode4ViewController.m file make the following changes.
#import "HelloWorld_Xcode4ViewController.h"
@implementation HelloWorld_Xcode4ViewController
@synthesize label;
-(IBAction)buttonPressed{
        if ([label.text isEqualToString:@"Hello World!!!"])
                label.text = @"Hello iPhone!!!";
        else
                label.text = @"Hello World!!!";
}
- (void)dealloc
{
    [super dealloc];
}
- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn’t have a superview.
    [super didReceiveMemoryWarning];
 
    // Release any cached data, images, etc that aren’t in use.
}
- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
Step 7: Now Compile and Run the application and see the Output in the Simulator.

這個網誌中的熱門文章

正確設置404頁面及其他.505,500....

正確設置404頁面 404頁面的設置是否正確直接關係到網站粘性,而現在很多網站的錯誤頁面返回碼都是200和302,只要蜘蛛爬行錯誤頁面不是404,那麼你的404頁 面設置就是錯誤的了,這裡跟大家介紹如何正確設置404頁面。 怎麼正確設置404頁面?很多人看到這個話題可能覺得下文不屑一顧,其實你是否知道自己的404頁面有沒有設置正確呢?很多開源的cms系統和博客 系統都會帶有404頁面,你是不是覺得這樣已經ok了?不用設置了?這些想法是錯誤的,我們做優化的時候,應該測試404頁面時候生效,設置是否正 確等。下面我們詳細說明怎麼設置404頁面。 這先說一下怎麼樣的404頁面才是有效的404頁面。大家應該都知道搜索引擎是通過http狀態碼來識別網頁狀態的,那麼當蜘蛛檢索到一個錯誤鏈 接時,就需要返回404狀態碼來告訴搜索引擎,這個頁面是錯誤頁面,以後不用索取了。而如果返回200,則告訴搜索引擎這個頁面是正常頁面。 所以我們要查看網站錯誤頁面的返回碼是200還是404,而現在很多網站的404頁面返回碼是200而不是404.    那怎麼正確設置404頁面?

Mac OS X Server 架設兩個網站、兩個郵件伺服器

from:http://www.bnw.com.tw/conference/viewtopic.php?t=208 我的需求要更簡單。  朋友的工作室就兩三人而已,另外一個工作室也是兩三人。  希望有屬於自己的網站及網域名稱郵件  www.123.com   abc@123.com  

Mac mini server(2012 年末和 2011 年中):如何將 OS X Server 安裝到軟體 RAID

重要事項 這些步驟會清除 Mac mini Server 中兩個磁碟機上的所有資料。雖然您可以重新安裝 OS X Server,但是請務必確認這些磁碟機上的任何其他資料都已完成備份,然後再繼續。 您無法在 RAID 卷宗上建立恢復分割區。如果沒有恢復分割區, 將無法支援 OS X 的某些功能 ,因此您應該考慮使用 恢復磁碟輔助程式 建立外接恢復磁碟,然後才建立 RAID 卷宗。 本文所提供的步驟需要使用透過 WiFi 或乙太網路的寬頻 Internet 連線。您的網路連線必須符合 這篇連結文章 的「重新安裝 OS X 的需求」一節中,針對 Internet 回復功能所述的需求。 安裝步驟 按住 Command、Option 和 R 鍵的同時啟動 Mac mini Server,以便啟動進入 Internet 回復模式。這可能要花數分鐘的時間。看到旋轉地球和“正在從網路啟動回復程序”訊息時,放開這些按鍵。