Results 1 to 11 of 11
  1. #1


    Member Since
    Mar 13, 2012
    Posts
    8
    I'm new to Xcode and I'm having some trouble with finishing my say hello script.
    So I need some help finishing this script that I started working on in xcode 4.5.2

    It's a simple say hello script for the iphone that I'm working on., it's supposed to say hello. How ever I'm having problems with the source code in viewcontroller .m. Every time I try these codes

    _displayLabel.text = @"hello world"
    _label.text = @"hello world"

    None of them work.. Can any one help?

  2. #2


    Member Since
    Mar 13, 2012
    Posts
    8
    Hey if I've worded any thing funny, it's because I'm really new to this all. I could really use some help none the less.

  3. #3

    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    186
    Post all of the code you have so far, and someone might be able to help you.

    Regards Mark

  4. #4


    Member Since
    Mar 13, 2012
    Posts
    8
    //
    // ViewController.m
    // hello world
    //
    // Created by DEEPseaDIVER on 11/21/12.
    // Copyright (c) 2012 DEEPseaDIVER. All rights reserved.
    //

    #import "ViewController.h"

    @interface ViewController ()

    @end

    @implementation ViewController

    - (void)viewDidLoad
    {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    }

    - (void)didReceiveMemoryWarning
    {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    }

    - (IBAction)startpressedid)sender {
    }
    @end

  5. #5


    Member Since
    Mar 13, 2012
    Posts
    8
    Quote Originally Posted by Mark FX View Post
    Post all of the code you have so far, and someone might be able to help you.

    Regards Mark
    Just posted it.

  6. #6

    Raz0rEdge's Avatar
    Member Since
    Jul 17, 2009
    Location
    MA
    Posts
    8,356
    Specs:
    27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3
    Where are you IBOutlets to get access to the labels? Did you hook up a button to the IBAction "startpressed"??
    --
    Regards
    ...Ashwin



    Be sure to read the Community Guidelines | The more information you provide, the better answers you get, remember GIGO.

  7. #7


    Member Since
    Mar 13, 2012
    Posts
    8
    Quote Originally Posted by Raz0rEdge View Post
    Where are you IBOutlets to get access to the labels? Did you hook up a button to the IBAction "startpressed"??
    I don't think I put a Iboutlet in, the video I watched did not have this info. And yes the IBAction is hooked up to the startpressed button.

  8. #8

    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    186
    Firstly you posted iOS code in the OSX forum, this does matter as to assign text to a NSTextField control in an Mac project, is different to assigning text to a UITextField in an iOS project.

    Secondly you listed this code in your first post.
    _displayLabel.text = @"hello world"
    _label.text = @"hello world"

    But in your next posting you've put some code for a View Controller Implementation class that does not show the above code in it, you've not shown the interface .h file for the same View Controller .m class file.

    So you have not posted all of the code, so it is hard for us to help you.

    But as RazOrEdge has pointed out, you have to have IBOutlets linked for the Text Fields in your Interface Builder xib file, if you dont have these IBOutlets, you cannot assign text to the Text Field controls.

    For Example

    Code:
    // .h file
    
    @interface myClass : NSObject
    {
        IBOutlet UITextField *myTextField;
    }
    
    @property (nonatomic, readonly, strong)IBOutlet UITextField *myOtherTextField;
    
    @end
    
    // .m file
    
    @implementation myClass
    
    @synthesize myOtherTextField;
    
    - (id)init
    {
        self = [super init];
    
        if (self) {
            myTextField.text = @"Hello";
            myOtherTextField.text = @"World";
        }
        return self;
    {
    
    @end
    In the above sudo code, I would have to link the two IBOutlets to the Text Fields in my Interface xib file, if I dont, then the text would not appear in the Text Fields.

    Lastly I noticed your using dot notation in your code, which I have also done, but you should consider using Objective-C style coding, using square braces like this.

    Code:
    [myTextField setText: @"Hello"];
    the reason for this is as you start to deal with more Cocoa Touch Framework classes, some
    of there Methods are only accessible with this type of syntax.

    Hope this is of some help, but unless you post all of the relevant code from your project, we will not be able to help you more.

    Regards Mark

  9. #9


    Member Since
    Mar 13, 2012
    Posts
    8
    ]
    Quote Originally Posted by Mark FX View Post
    Firstly you posted iOS code in the OSX forum, this does matter as to assign text to a NSTextField control in an Mac project, is different to assigning text to a UITextField in an iOS project.

    Secondly you listed this code in your first post.
    _displayLabel.text = @"hello world"
    _label.text = @"hello world"

    But in your next posting you've put some code for a View Controller Implementation class that does not show the above code in it, you've not shown the interface .h file for the same View Controller .m class file.

    So you have not posted all of the code, so it is hard for us to help you.

    But as RazOrEdge has pointed out, you have to have IBOutlets linked for the Text Fields in your Interface Builder xib file, if you dont have these IBOutlets, you cannot assign text to the Text Field controls.

    For Example

    Code:
    // .h file
    
    @interface myClass : NSObject
    {
        IBOutlet UITextField *myTextField;
    }
    
    @property (nonatomic, readonly, strong)IBOutlet UITextField *myOtherTextField;
    
    @end
    
    // .m file
    
    @implementation myClass
    
    @synthesize myOtherTextField;
    
    - (id)init
    {
        self = [super init];
    
        if (self) {
            myTextField.text = @"Hello";
            myOtherTextField.text = @"World";
        }
        return self;
    {
    
    @end
    In the above sudo code, I would have to link the two IBOutlets to the Text Fields in my Interface xib file, if I dont, then the text would not appear in the Text Fields.

    Lastly I noticed your using dot notation in your code, which I have also done, but you should consider using Objective-C style coding, using square braces like this.

    Code:
    [myTextField setText: @"Hello"];
    the reason for this is as you start to deal with more Cocoa Touch Framework classes, some
    of there Methods are only accessible with this type of syntax.

    Hope this is of some help, but unless you post all of the relevant code from your project, we will not be able to help you more.

    Regards Mark

    Alright thanks for correcting me mark this info is really helping a lot, here's the rest of the file.

    .h below

    //
    // AppDelegate.h
    // hello world
    //
    // Created by DEEPseaDIVER on 11/21/12.
    // Copyright (c) 2012 DEEPseaDIVER. All rights reserved.
    //

    #import <UIKit/UIKit.h>

    @interface AppDelegate : UIResponder <UIApplicationDelegate>

    @property (strong, nonatomic) UIWindow *window;

    @end


    .m below were the tutorial video said the code should be


    //
    // ViewController.m
    // hello world
    //
    // Created by DEEPseaDIVER on 11/21/12.
    // Copyright (c) 2012 DEEPseaDIVER. All rights reserved.
    //

    #import "ViewController.h"

    @interface ViewController ()

    @end

    @implementation ViewController

    - (void)viewDidLoad
    {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    }

    - (void)didReceiveMemoryWarning
    {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    }

    - (IBAction)startpressedid)sender {
    _displayLabel.text = @"hello world"
    }
    @end


    If I screwed any thing up please don't hesitate to correct me.

  10. #10

    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    186
    The code you have posted could not possibly be all of the code, because you have an AppDelegate.h interface file, but no matching AppDelegate.m implementation file, you need to have both for a complete class object.

    Also you have posted a ViewController.m implementation file, but no corresponding ViewController.h interface file, again you would need both to make a complete ViewController class, as in the generic code I posted above.

    I dont know which training video you are learning from, but my advice would be find alternative resources to learn from.
    It seems that you do not understand the basics of the Objective-C language, so I would advise you to stop where you are and learn that first before attempting to write an iOS app, this book below is a good start to learn the language first.

    Objective-C Programming: The Big Nerd Ranch Guide (Big Nerd Ranch Guides): Aaron Hillegass: 9780321706287: Amazon.com: Books

    After learning the Objective-C language, you can then move on to learn App development with the Xcode tools, with one of these books below.

    Cocoa Programming for Mac OS X (4th Edition): Aaron Hillegass, Adam Preble: 9780321774088: Amazon.com: Books

    iOS Programming: The Big Nerd Ranch Guide (3rd Edition) (Big Nerd Ranch Guides): Joe Conway, Aaron Hillegass: 9780321821522: Amazon.com: Books

    In short, your going to have to start at the begining, and take your time, there is no short cut to learn app development, it takes a long time, and hard work.

    I could write your code for you, but that would teach you nothing, and it would also leave you with no basic understanding of what and how the code works, so take my advise and get yourself some good books to learn from.

    Regards Mark

  11. #11


    Member Since
    Mar 13, 2012
    Posts
    8
    Quote Originally Posted by Mark FX View Post
    The code you have posted could not possibly be all of the code, because you have an AppDelegate.h interface file, but no matching AppDelegate.m implementation file, you need to have both for a complete class object.

    Also you have posted a ViewController.m implementation file, but no corresponding ViewController.h interface file, again you would need both to make a complete ViewController class, as in the generic code I posted above.

    I dont know which training video you are learning from, but my advice would be find alternative resources to learn from.
    It seems that you do not understand the basics of the Objective-C language, so I would advise you to stop where you are and learn that first before attempting to write an iOS app, this book below is a good start to learn the language first.

    Objective-C Programming: The Big Nerd Ranch Guide (Big Nerd Ranch Guides): Aaron Hillegass: 9780321706287: Amazon.com: Books

    After learning the Objective-C language, you can then move on to learn App development with the Xcode tools, with one of these books below.

    Cocoa Programming for Mac OS X (4th Edition): Aaron Hillegass, Adam Preble: 9780321774088: Amazon.com: Books

    iOS Programming: The Big Nerd Ranch Guide (3rd Edition) (Big Nerd Ranch Guides): Joe Conway, Aaron Hillegass: 9780321821522: Amazon.com: Books

    In short, your going to have to start at the begining, and take your time, there is no short cut to learn app development, it takes a long time, and hard work.

    I could write your code for you, but that would teach you nothing, and it would also leave you with no basic understanding of what and how the code works, so take my advise and get yourself some good books to learn from.

    Regards Mark
    I understand I guess the video I was learning from really wasn't that great. half the things you're telling me the video did not touch on so I will read more about this. Thanks again mark for sticking around and leading me through this, while I am a little disappointed I would never ask you or any one to write the code for me. The whole purpose of this post besides trying to finish my project was to learn, and I learned a lot.

    Thanks again guys!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. New to programming. Having trouble with Xcode
    By Chris23 in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 11-23-2010, 07:51 PM
  2. Shell Script in GeekTool trouble ...
    By TattooedMac in forum OS X - Development and Darwin
    Replies: 13
    Last Post: 11-13-2009, 07:16 PM
  3. C Program Trouble Compiling w/GCC, Trouble Running in Xcode
    By ebeccarayray in forum OS X - Apps and Games
    Replies: 1
    Last Post: 09-28-2009, 10:41 PM
  4. Call a script from Obj-c (or Xcode/Cocoa)
    By Konan in forum OS X - Development and Darwin
    Replies: 2
    Last Post: 08-30-2009, 01:29 AM
  5. XCode trouble
    By meskue in forum OS X - Apps and Games
    Replies: 0
    Last Post: 05-19-2006, 05:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •