Collection By traibingo
1
Bài 1: Giới thiệu các công cụ để lập
trình iPhone
Theo kinh nghiệm của tôi thì những người đã quá quen với hệ điều hành
windows và làm việc trên nền windows thì rất khó để mà thay đổi thói quen
sử dụng một hệ điều hành khác. Tuy nhiên, cũng theo kinh nghiệm của tôi
thì chỉ cần bỏ một thời gian ngắn chịu khó làm quen với cái mới thì ắt hẳn
sẽ thấy được nhiều điều thú vị mà bên windows không có. Lấy một ví dụ
điển hình như khi bạn chuyển từ windows sang MAC OS bạn sẽ thấy MAC
chẳng có gì hay ho cả, khó dùng, giao diện thì ko được bóng bẩy như
windows 7, khi cần ứng dụng cho MAC thì tìm lè lưỡi cũng chẳng ra, mà có
ra thì cũng khó tìm được bản crack.
Tất nhiên là cũng phải tuỳ vào tính chất công việc mà người ta nên chọn
hệ điều hành nào cho phù hợp. Ở đây, công việc của chúng ta là lập trình
ứng dụng trên iPhone nên MAC OS là một trong số các yếu tố mà bạn phải
có. Ngoài ra, để lập trình được ứng dụng iPhone bạn cần có 1 bộ iPhone
SDK do Apple cung cấp, phiên bản mới nhất hiện nay là 3.1.2 và một bộ
XCode cùng phiên bản dùng để coding và kéo thả giao diện.
iPhone SDK và XCode thì có thể dễ dàng download tại trang web của
Apple còn MAC OS thì tốt nhất là mua đĩa dành cho PC. Việc cài đặt MAC
OS trên PC thực sự không phải dễ dàng chút nào vì theo như kinh nghiệm
cài MAC của tôi thì mỗi máy PC có một dòng MAC OS riêng được hack để
có thể làm việc được trên nền phần cứng tương ứng. Do đó mà khi bạn
chọn mua đĩa MAC nên chú ý đến cấu hình phần cứng của máy. Chẳng
hạn như card âm thanh là do realtek sản xuất hay hãng khác, card đồ hoạ
Bài 2: UITableView Hello world
Trong bài này sẽ hướng dẫn cho các bạn cách tạo một ứng dụng "Hello
world" sử dụng UITableView.
Mục tiêu của bài học:
- Create a New Navigation-Based Application
- Learn About the Default Files
- Update the UITableView Cells to Display “Hello World” Text
Creating a New Navigation-Based Application
Start a new iPhone OS Project
Click Xcode > New Project and a window should pop up like this:
Make sure Application is selected under iPhone OS and then select
Navigation-Based Application. Click Choose… It will ask you to name
your project. Type in “Hello World” and let‟s get started.
Learn About the Default Files
Collection By traibingo
4
What is all this stuff?
There are quite a few files that get added to your project. At first glance,
this looks kind of intimidating. Don‟t worry, we only need to edit one of
them. Here is a quick explanation of the different files. You don‟t have to
read this part but having this many files is what confused me the most
when I started developing for the iPhone.
1. CoreGraphics.framework,Foundation.framwork, UIKit.framework –
You guessed it, this is a set of library functions provided by Apple that we
use in our application. We use these as includes similar to any other
language that includes library functions.
Collection By traibingo
5
Now, all of these files together create a basic program. Go ahead and click
on the Build and Go button at the top of Xcode. Make sure the drop-down
on the top left says Simulator | Debug, this tells Xcode that we are testing
on the iPhone simulator.
You will see the iPhone simulator start and your program will launch. It‟s
not very interesting at the moment. All it shows is the Table View that Apple
has added for us. So what we are going to do is add a row to this table
view.
Update the UITableView Cells to Display “Hello World” Text
Let’s write some code