New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

I'm new to Xcode and I'm having some trouble with finishing my say hello script.


Post Reply New Thread Subscribe

 
Thread Tools
raindroprainbow

 
Member Since: Mar 13, 2012
Posts: 8
raindroprainbow is on a distinguished road

raindroprainbow is offline
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?
QUOTE Thanks
raindroprainbow

 
Member Since: Mar 13, 2012
Posts: 8
raindroprainbow is on a distinguished road

raindroprainbow is offline
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.
QUOTE Thanks
Mark FX

 
Mark FX's Avatar
 
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 168
Mark FX has a spectacular aura about

Mark FX is offline
Post all of the code you have so far, and someone might be able to help you.

Regards Mark
QUOTE Thanks
raindroprainbow

 
Member Since: Mar 13, 2012
Posts: 8
raindroprainbow is on a distinguished road

raindroprainbow is offline
//
// 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
QUOTE Thanks
raindroprainbow

 
Member Since: Mar 13, 2012
Posts: 8
raindroprainbow is on a distinguished road

raindroprainbow is offline
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.
QUOTE Thanks
Raz0rEdge

 
Raz0rEdge's Avatar
 
Member Since: Jul 17, 2009
Location: MA
Posts: 7,501
Raz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant future
Mac Specs: 27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3

Raz0rEdge is offline
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.
QUOTE Thanks
raindroprainbow

 
Member Since: Mar 13, 2012
Posts: 8
raindroprainbow is on a distinguished road

raindroprainbow is offline
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.
QUOTE Thanks
Mark FX

 
Mark FX's Avatar
 
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 168
Mark FX has a spectacular aura about

Mark FX is offline
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
QUOTE Thanks
raindroprainbow

 
Member Since: Mar 13, 2012
Posts: 8
raindroprainbow is on a distinguished road

raindroprainbow is offline
]
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.
QUOTE Thanks
Mark FX

 
Mark FX's Avatar
 
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 168
Mark FX has a spectacular aura about

Mark FX is offline
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
QUOTE Thanks
raindroprainbow

 
Member Since: Mar 13, 2012
Posts: 8
raindroprainbow is on a distinguished road

raindroprainbow is offline
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!
QUOTE Thanks

Post Reply New Thread Subscribe


« Programming for Dummies. Need help please | Darwin Streaming Server »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

All times are GMT -4. The time now is 02:38 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?