TAILIEUCHUNG - Learn Objective C on the Mac phần 2

. main () sử dụng hai chức năng này để so sánh các số nguyên và in ra kết quả. Tạo dự án cho Đảng BOOL là chính xác giống như quá trình thực hiện dự án Xin chào Mục tiêu-C: 1. Xcode khởi động, nếu nó chưa được chạy. 2. Chọn New Project từ trình đơn File. 3. Chọn tiện ích dòng lệnh trên bên trái và Công cụ Foundation trên | 14 CHAPTER 2 Extensions to C Mighty BOOL in Action To show mighty BOOL in action we move on to our next project - BOOL Party which compares pairs of integers to see if they re different. Aside from main the program defines two functions. The first areIntsDifferent takes two integer values and returns a BOOL YES if the integers are different and NO if they are the same. A second function boolStringO takes a BOOL parameter and returns the string @ YES if the parameter is YES and @ NO if the parameter is NO. This is a handy function to have around when you want to print out a human-readable representation of BOOL values. main uses these two functions to compare integers and print out the results. Creating the project for BOOL Party is exactly the same process as making the project for Hello Objective-C 1. Launch Xcode if it s not already running. 2. Select New Project from the File menu. 3. Choose Command Line Utility on the left and Foundation Tool on the right. 4. Click Choose. 5. Type BOOL Party as the Project Name and click Save. Edit BOOL to make it look like this import Foundation returns NO if the two integers have the same value YES otherwise BOOL areIntsDifferent int thing1 int thing2 if thing1 thing2 return NO else return YES areIntsDifferent given a YES value return the human-readable string YES . Otherwise return NO NSString boolString BOOL yesNo if yesNo NO return @ NO CHAPTER 2 Extensions to C 5 else return @ YES boolString int main int argc const char argv BOOL areTheyDifferent areTheyDifferent areIntsDifferent 5 5 NSLog @ are d and d different @ 5 5 boolString areTheyDifferent areTheyDifferent areIntsDifferent 23 42 NSLog @ are d and d different @ 23 42 boolString areTheyDifferent return 0 main Build and run your program. You ll need to bring up the Console window to see the output by choosing Console from the Run menu or using the keyboard shortcut R. In the Run Debugger Console window you should see output like the .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.