Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1

    Retired Prophet
    ToxicJew.'s Avatar
    Join Date
    Mar 2011
    Location
    S̢͎̳̞̲͈̪̳̻ͮͩt̟̳̏ͬ̔&#
    Posts
    7,781
    Points
    7,586
         User Info     Contact     Gamer ID
    Join Date
    Mar 2011
    Location
    S̢͎̳̞̲͈̪̳̻ͮͩt̟̳̏ͬ̔&#
    Posts
    7,781
    Points
    7,586

    Contact info:

    Youtube Channel: http://www.youtube.com/kennethbgoodin

    Default Xcode 4: Walking Through Your First iPhone Application.

    You need a Mac to use Xcode.

    If you haven't yet, check out my first tutorial on the basic components of Xcode here.

    This tutorial will be walking you through coding your first (basic) iPhone app. This won't be a "here's some code, paste it in" kind of thing. I have made an effort to explain what everything does. So, let's get started.

    You'll want to start by opening Xcode, of course. Once in Xcode, you may see a screen like this if you've already made a few projects:



    Just click, "Create a new Xcode project." it's the first option on the list at the left.

    Once you do that, you'll see a list come down with some different templates for you to choose from. Select iOS if it is not already selected, and then Application. Under Application you'll see a variety of different templates for you to choose from. Look for "Single View Application" and select it, or if you don't have that option, select "View Based Application."



    Note: Mine has an extra set of templates added to iOS, because of a plugin i installed called iOSOpenDev.

    Next you'll see this screen:



    This just allows you to choose the name of your product, the name of your company, and the prefixes of the classes. To make things easier you should use the same thing for the Name and ClassPrefix, or something similar. The device family is the devices you are building your app for; iPhone or iPad, or both.

    The company identifier is whatever you want it to be if you're a solo developer. Mine is simple: kGoodin. You can leave the other options alone, and click Next.

    You'll get a pulldown menu asking you where you want to save your app, just pick anywhere, it doesn't matter.

    Next you'll see this screen:



    If you remember from my first tutorial, mentioned above, the ViewController.h and ViewController.m are where you want to go to start coding. But we'll look at those later, for now we're going to look at the .storyboard files. If you are using an older version of Xcode you will have .xib files instead of .storyboard.

    Note: If you chose Universal as your Device Family, mentioned above, then you will have two .storyboard files, one for iPhone and iPad.

    So, click the .storyboard file, and you should see this:



    This is, basically, what your app will look like on an iPhone. Because you haven't input any code or added any objects yet, it's blank.

    To the bottom right you should see a small box with different Objects in it.



    If you do not have Objects in your box, check the top row of buttons. Make sure the Object Library one is highlighted (it's the third one to the right.)

    Once inside the Object Library, you have a slew of different Objects to choose from, to place on your device. For now I'm going to be adding a Label, a Round Rect Button, and a Text Field.







    Start by dragging the three objects anywhere on your iDevice screen in the .storyboard.



    I have labeled my three Objects with basic things describing them, for now. Those will change once i start inputting my code.

    To change the text, color, and more of your Objects, select an Object and look at the column to the right, above the Object Library.



    Now that we have the three elements of our app, we'll start by entering the header file, the ViewController.h.



    What we're going to do is declare the outlets that we defined in the .storyboard: the label, the text field, and the round rect. button.

    The first thing we'll do is add a curly bracket, a "{" right after the UIViewController on the @interface line. This bracket tells Xcode that everything inside the brackets applies to the current view, the UIView.

    Next we'll type:
    Code:
    IBOutlet UILabel *hello ;
    IBOutlet UITextField *name ;
    }
    between the @interface HelloYouViewController : UIViewController { and the @end

    Your .h should now look like this:



    Let's look at each part of this code separately, and figure out what it means.

    IBOutlet is a macro defined to denote variables and methods that can be referred to. The UILabel and the UITextField just tell Xcode what Object the IBOutlet's are tied to. The *hello and *name are the variables. The semi-colons just signify the end of that line.

    Got it?

    Good. Next we'll add another line of code, to tell our button what to do.
    Code:
    -(IBAction) ChangeTextOfHello ;
    Now your .h should look like this:



    Notice the highlighted text, that's what we just added.

    An IBAction is just a way to link an action to your Interface Builder (your .storyboard file.) You can name the text after it "changeTextOfHello" anything you want, i just chose that because it modifies my Hello label.

    That's it for the .h, now we move on to the .m.



    We're going to ignore all of this code implemented automatically, by Apple, for now. We are going to add the following code:
    Code:
    NSString *string1 = @"Hello " ;
    
    -(IBAction) ChangeTextOfHello
    {
    	hello.text = [string1 stringByAppendingString:name.text] ;
    Your .m should now look like this:



    You can stick the code anywhere between the @implentation and @end statements, i just chose below all of the memory usage stuff.

    NSString is implemented to represent Unicode characters; basically, a text string. It is immutable, meaning it cannot be changed. *string1 = @"Hello " defines the name of our first string. Next, we attach an IBAction referencing the ChangeTextOfHello action we defined in the .h. After this we set what hello.text is with hello.text = [string1 stringByAppendingString:name.text.] ; string1 is the string we defined in the NSString line.

    Once you've got all that in, go back to your .storyboard.

    Right underneath the diagram of your iPhone view, you'll see an orange box and an white box inside a circle. Right click the box inside the circle. This may also be displayed on the left side as an orange rectangle with white sides, depending on what version of Xcode you have.



    Once you right click it, you'll see a black box with a lot of different options. Using this orange circle, called the View Controller, you can connect your code to your .storyboard, meaning you can make the app do what you want it too.



    Look at the bottom of this list of options, under the Received Actions subheading. You should see the action we defined in the delegate files (.h and .m) Mine is called ChangeTextOfHello. Drag this to your round rect. button. This will open up another menu of options.



    These options are different ways you want the button to react to the proposed action. Select "Touch Up Inside" This will set it so that the button does the action we previously defined whenever the user taps on it.

    Next you right click the ViewController again and select the first option under Outlets, hello, and drag it to the Label we placed earlier.



    Next drag the name option right below hello onto the text field.

    That's it, you're done! Now just click Run in the top right corner, and wait for Xcode to compile it. Once it loads the iOS simulator, you can see your app in action.



    So there you have it. If you have trouble understanding any of this, or any questions, feel free to ask. Try rereading sections you don't really comprehend.

    You may have noticed, you can't dismiss the keyboard in this app. That is covered in my next tutorial, check it out by going here.

    0 Not allowed! Not allowed!
    Last edited by ToxicJew.; 03-15-2012 at 12:52 PM.
    ส็็็็็็็็็็็็็็็็็็็็็็็็็༼ ຈل͜ຈ༽ส้้้้้้้้้้้้้้้้้้้้้้้ส็็็็็็็็็็็็็็็็็็็็ ็็็็็༼ ຈل͜ຈ༽ส้้้้้้้้้้้้้้้้้้้้้้้

  2. #2
    mini mini's Avatar
    Join Date
    Aug 2011
    Location
    Minnesota
    Posts
    1,988
    Points
    2,840
         User Info     Contact     Gamer ID
    Join Date
    Aug 2011
    Location
    Minnesota
    Posts
    1,988
    Points
    2,840
    Gamer IDs

    PSN ID: minnesotastyle

    Contact info:

    Youtube Channel: www.youtube.com/user/codeleakerforums

    Default

    Um maybe i didnt really read it well enough but what language is this written in?

    the code that is

    0 Not allowed! Not allowed!


  3. #3

    Retired Prophet
    ToxicJew.'s Avatar
    Join Date
    Mar 2011
    Location
    S̢͎̳̞̲͈̪̳̻ͮͩt̟̳̏ͬ̔&#
    Posts
    7,781
    Points
    7,586
         User Info     Contact     Gamer ID
    Join Date
    Mar 2011
    Location
    S̢͎̳̞̲͈̪̳̻ͮͩt̟̳̏ͬ̔&#
    Posts
    7,781
    Points
    7,586

    Contact info:

    Youtube Channel: http://www.youtube.com/kennethbgoodin

    Default

    Applications are written in Objective-C. Objective-C is an object oriented language which lies on top of the C language.

    0 Not allowed! Not allowed!
    Last edited by ToxicJew.; 03-12-2012 at 02:02 PM.
    ส็็็็็็็็็็็็็็็็็็็็็็็็็༼ ຈل͜ຈ༽ส้้้้้้้้้้้้้้้้้้้้้้้ส็็็็็็็็็็็็็็็็็็็็ ็็็็็༼ ຈل͜ຈ༽ส้้้้้้้้้้้้้้้้้้้้้้้

  4. #4
    Banned
    Join Date
    Oct 2011
    Posts
    863
    Points
    1,141
         User Info     Contact     Gamer ID
    Join Date
    Oct 2011
    Posts
    863
    Points
    1,141
    Gamer IDs

    Steam ID: buttholemonger

    Contact info:

    Youtube Channel: youtube.com/triixsoldier

    Default

    DUDE!!! I am stoked to start an app! THANKS JEW!

    0 Not allowed! Not allowed!

  5. #5
    mini mini's Avatar
    Join Date
    Aug 2011
    Location
    Minnesota
    Posts
    1,988
    Points
    2,840
         User Info     Contact     Gamer ID
    Join Date
    Aug 2011
    Location
    Minnesota
    Posts
    1,988
    Points
    2,840
    Gamer IDs

    PSN ID: minnesotastyle

    Contact info:

    Youtube Channel: www.youtube.com/user/codeleakerforums

    Default

    can this be used to create games and where are some tuts on Objective C?

    0 Not allowed! Not allowed!


  6. #6

    Retired Prophet
    ToxicJew.'s Avatar
    Join Date
    Mar 2011
    Location
    S̢͎̳̞̲͈̪̳̻ͮͩt̟̳̏ͬ̔&#
    Posts
    7,781
    Points
    7,586
         User Info     Contact     Gamer ID
    Join Date
    Mar 2011
    Location
    S̢͎̳̞̲͈̪̳̻ͮͩt̟̳̏ͬ̔&#
    Posts
    7,781
    Points
    7,586

    Contact info:

    Youtube Channel: http://www.youtube.com/kennethbgoodin

    Default

    I have a tutorial on Objective C in the Jailbreaking Tutorials section of the List, in my sig.

    There is also a beginners tutorial at the top of this one. But you will need a Mac to use Xcode, or a Hackintosh.

    0 Not allowed! Not allowed!
    ส็็็็็็็็็็็็็็็็็็็็็็็็็༼ ຈل͜ຈ༽ส้้้้้้้้้้้้้้้้้้้้้้้ส็็็็็็็็็็็็็็็็็็็็ ็็็็็༼ ຈل͜ຈ༽ส้้้้้้้้้้้้้้้้้้้้้้้

  7. #7
    mini mini's Avatar
    Join Date
    Aug 2011
    Location
    Minnesota
    Posts
    1,988
    Points
    2,840
         User Info     Contact     Gamer ID
    Join Date
    Aug 2011
    Location
    Minnesota
    Posts
    1,988
    Points
    2,840
    Gamer IDs

    PSN ID: minnesotastyle

    Contact info:

    Youtube Channel: www.youtube.com/user/codeleakerforums

    Default

    i have windows 7 PC. does hackintosh allow it to work on PC?

    0 Not allowed! Not allowed!


  8. #8

    Retired Prophet
    ToxicJew.'s Avatar
    Join Date
    Mar 2011
    Location
    S̢͎̳̞̲͈̪̳̻ͮͩt̟̳̏ͬ̔&#
    Posts
    7,781
    Points
    7,586
         User Info     Contact     Gamer ID
    Join Date
    Mar 2011
    Location
    S̢͎̳̞̲͈̪̳̻ͮͩt̟̳̏ͬ̔&#
    Posts
    7,781
    Points
    7,586

    Contact info:

    Youtube Channel: http://www.youtube.com/kennethbgoodin

    Default

    A Hackintosh is any computer that is not a Mac that can run OS X. No more off topic questions, google it.

    0 Not allowed! Not allowed!
    ส็็็็็็็็็็็็็็็็็็็็็็็็็༼ ຈل͜ຈ༽ส้้้้้้้้้้้้้้้้้้้้้้้ส็็็็็็็็็็็็็็็็็็็็ ็็็็็༼ ຈل͜ຈ༽ส้้้้้้้้้้้้้้้้้้้้้้้

  9. #9
    mini mini's Avatar
    Join Date
    Aug 2011
    Location
    Minnesota
    Posts
    1,988
    Points
    2,840
         User Info     Contact     Gamer ID
    Join Date
    Aug 2011
    Location
    Minnesota
    Posts
    1,988
    Points
    2,840
    Gamer IDs

    PSN ID: minnesotastyle

    Contact info:

    Youtube Channel: www.youtube.com/user/codeleakerforums

    Default

    okeedokee

    0 Not allowed! Not allowed!


  10. #10
    Josh's Avatar

    Badge

    Join Date
    Dec 2009
    Location
    Florida .
    Posts
    10,473
    Points
    11,216
         User Info     Contact     Gamer ID
    Join Date
    Dec 2009
    Location
    Florida .
    Posts
    10,473
    Points
    11,216

    Default

    I need a Hackintosh whenever I get my own computer/laptop .

    Jew, we're one step closer to creating our app business :3

    0 Not allowed! Not allowed!
    Collabo with my boi Artemis :3



Tags for this Thread

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -10. The time now is 04:21 AM.
Powered by vBulletin®
Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.