↑ ↓

Vietmobile.vn - Chuyên trang về điện thoại và thiết bị di động

    #import
    Viết ứng dụng cho iphone, 1/6/11
  1. noname

    Click next. Give your class a name (I’m going to call it “Person”), and click finish.
    Now we have two files. For me they are Person.h and Person.m.
    The .h files has an interface, it starts with “@interface” and ends with “@end”. Here is where you say to the world how you are going to define your class. Inside the curly braces is where we define the variables and outside you define the public methods names and the parameters it is going to receive. Other kind of methods, like the private ones are defined in the implementation.
    Let’s add a variable.
    @interface Person : NSObject { NSString *Name; } @endI added a name which is a string. Now let’s add some behaviors (Remember, outside the curly braces).
    - (void) walk; - (void) setName: (NSString) a;I typed a minus (-) sign because this is an instance level method, this are me mayority of the methods that we are going to use. If you see at any moment one with a plus (+) sing, that means it is a class level method. Within parenthesis i typed void because this is a procedure, it does not returns any value. The second procedure takes a value, we are going to talk about it when we talk about method specifically.
    Your “.h” file should look like this:
    #import @interface Person : NSObject { NSString *Name; } - (void) walk; - (void) setName: (NSString *) a; @end Methods

    Open Person.m. Within the @implementation we are going to say what our methods do. Let’s add the methods.
    -(void) walk { NSLog(@"Hi, i'm @% and i'm walking",Name); } -(void) setName:(NSString *)a{ Name = a; }In the first method we use NSLog, it is a built in method, it is used to print out messages through the console. You can open it at Run->Console if you want to test this codes when we finish the tutorial.
    The @% sign means that there goes a string variable, it is specified at the end of the line, in this case the name of the person.
    The second method sets the value of the name to a. In Objective-C, parameters are not defined like most of other languages, it has to be done like you where talking to the computer. A better example of it could be this:
    -(void) CreateHouse:(NSString *)name withNumberOfDoors:(int)numDoors andWindowsColor:(NSString *)color;After this your implementation file should look like this:
    #import "Person.h" @implementation Person -(void) walk { NSLog(@"Hi, i'm %@ and i'm walking",Name); } -(void) setName:(NSString *)a{ Name = a; } @endNow Calling methods is very easy. You have to create an instance of the class and call the method you need. For example, if you are willing to test your code and you created a Command Line Utility with Foundation Tool, you are going to find a file that has the same name of your project in the “Source” folder. Open it.
    There is the main function, it is the first that is called when the application start.
    Let’s import the class we just created adding #import “Person.h” right after #import and erase everything within the main method except for the return command.
    Now we create an instance of our class:
    Person *p = [Person new];Then we set the name by calling a method. In Objective-C we call methods within [ ]:
    [p setName:mad:"Oscar"];We are saying, object p set the name of the person to “Oscar”
    And finally we call the walk method:
    [p walk];Your main file should look like this:
    #import #import "Person.h" int main (int argc, const char * argv[]) { Person *p = [Person new]; [p setName:mad:"Oscar"]; [p walk]; return 0; }Now if you want to test it you have to go to Run->Console, and hit “Build and Run”
    <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

     
    Conclusion

    We have learned the very basics of Objective-C. In the next tutorial we are going to talk about memory management, delegation and we are going to build a basic iphone app start working with some interaction.

    Here is some good resources. To get you learning....

    E-Books :
    Objective-C For Dummies



    [​IMG]
    Objective-C For Dummies
    For Dummies || ISBN: 0470522755 | 456 pages | PDF | 6 MB ​

    The only thing hotter than the iPhone right now is new apps for the iPhone. Objective–C is the primary language for programming iPhone and Mac OS X applications, and this book makes it easy to learn Objective–C.


    <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

     
    <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

     


    <<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>

    Head First iPhone Development

    A Learner's Guide to Creating Objective-C Applications for the iPhone

    <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

     


    Dan Pilone, Tracey Pilone "Head First iPhone Development (With Source Code)"
    English | ISBN-13: 978-0-596-80354-4 | PDF | 18.5 MB​


    Let's say you have an idea for a killer iPhone app. Where do you begin? Head First iPhone Development will help you get your first application up and running in no time. You'll quickly learn to use iPhone SDK tools, including Interface Builder and Xcode, and master Objective-C programming principles that will make your app stand out. It's a complete learning experience for creating eye-catching, top-sellingiPhone applications.

    * Put Objective-C core concepts to work, including message passing, protocols, properties, and memory management
    * Take advantage of iPhone patterns such as datasources and delegates
    * Preview your applications in the iPhone Simulator
    * Build complicated interactions that utilize multiple views, data entry/editing, and iPhone rotation
    * Work with iPhone's camera, GPS, and accelerometer
    * Optimize, test, and distribute your application

    We think your time is too valuable to waste struggling with new concepts. Using the latest research in cognitive science and learning theory to craft a multi-sensory learning experience,Head First iPhone Development provides a visually-rich format designed for the way your brain works, not a text-heavy approach that puts you to sleep.

    Download :
    <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

     ​

    Support forum ​
    <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

     ​


    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    [​IMG]
    Beginning Mac Programming: Develop with Objective-C and Cocoa

    Beginning Mac <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

     : Develop with Objective-C and Cocoa
    Pragmatic Bookshelf | ISBN: 1934356514 | edition 2010-03-26 |
    <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

      | 352 pages | 5.52 MB

    Beginning Mac Programming takes you through concrete, working examples, giving you the core
    <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

      and principles of development in context so you will be ready to build the <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

      you've been imagining. It <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

      you to Objective-C and the Cocoa framework in clear, easy-to-understand lessons, and demonstrates how you can use them together to write for the Mac, as well as the iPhone and iPod.

    You'll explore crucial developer tools like Xcode and Interface Builder, and learn the principles of object-oriented programming, and how memory, data, and storage work to help you build your software.

    If you've ever wanted to develop software for the Mac, this book is for you.


    <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

     
    Password default: shytex.com


    <<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    Cocoa Programming for Mac OS X (3rd Edition)

    [​IMG]
    Addison-Wesley Professional | ISBN: 0321503619 | May 15, 2008 | 464 pages | PDF | 18 MB
    If you’re developing applications for <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

      X, Cocoa® <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

      for Mac® OS X, Third Edition, is the book you’ve been waiting to get your hands on. If you’re new to the Mac environment, it’s probably the book you’ve been told to read first. Covering the bulk of what you need to know to develop full-featured applications for OS X, written in an engaging <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

      style, and thoroughly class-tested to assure clarity and accuracy, it is an invaluable resource for any Mac programmer.
    Download Links (18 Mb)
    <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

     
    Mirror :
    <Bạn vui lòng đăng nhập hoặc đăng ký để xem được nội dung này!>

     
    Pass :joinebook.com

Google+