Previous 1 2 Next 17 Replies Latest reply: Apr 16, 2012 5:22 PM by etresoft
claimsfour Level 1 Level 1 (0 points)

Hi Folks,

 

I literally spent an entire night trying to solve this...scoured the net/read tons of cryptic

articles.  I really am on my last braincell here and would appreciate if someone can help me.

 

I am trying to create a simple app in OSX where I click on a thumbnail size picture

and a random bit of text will appear. 

 

The Interface is a simple window with a simple picture, text label.  I associated everything

via the delegate...yet the code keeps giving me this error message.  I read that the 'string'

needs to be modified (and this is where I start losing my hair)

 

Below is the code I wrote:

 

The Header:

 

#import <Cocoa/Cocoa.h>

 

@interface AppAppDelegate : NSObject <NSApplicationDelegate> {

@private

   

    NSTextField *textoutput;

}

 

- (IBAction)button2:(id)sender;

@property (assign) IBOutlet NSTextField *textoutput;

 

@end

 

And the Implement:

 

#import "AppAppDelegate.h"

 

@implementation AppAppDelegate;

@synthesize textoutput;

 

 

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification

{

   int randomnumber = arc4random() % 3+1;

       - (IBAction)button2:(id)sender {

        switch ([sender randomnumber]) {

            case 1:

                textoutput.text = @"Test1";

                break;

            case 2:

                textoutput.text = @"Test2";

                break;

            case 3:

                textoutput.text = @"Test3";

                break;

            case 4:

                textoutput.text = @"Test4";

                break;

               

            default break;

        }

   

}

 

}

 

@end

 

Highlighted in red: I keep getting a "Expected Expression"  error or some other cryptic error message.

 

I would greatly appreciate any help/advice/corrections!  Someone helped me before with a simple 'dice' game

and that help helped me beyond all comprehension in basic coding...I now want to figure out the User Interface!!!

 

Thanks

  • etresoft Level 7 Level 7 (26,870 points)

    You can't define one function inside another.

  • HyperNova Software Level 6 Level 6 (8,275 points)

    "I keep getting a "Expected Expression"  error or some other cryptic error message."

     

    You have to state EXACTLY what the error message is.

  • claimsfour Level 1 Level 1 (0 points)

    etresoft wrote:

     

    You can't define one function inside another.

     

    Can you please explain to me in laymen's terms what this means?  I gather the following below is too 'nested'?  How do you correct it?

     

    Thank you.

     

    #import "SpenceAppAppDelegate.h"

     

    @implementation SpenceAppAppDelegate;

    @synthesize textoutput;

     

     

    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification

    {

       int randomnumber = arc4random() % 3+1;

       

       - (IBAction)button2:(id)sender {

            switch ([sender randomnumber]) {

                case 1:

                    textoutput.text = @"Test1";

                    break;

                case 2:

                    textoutput.text = @"Test2";

                    break;

                case 3:

                    textoutput.text = @"Test3";

                    break;

                case 4:

                    textoutput.text = @"Test4";

                    break;

                   

                default break;

            }

       

    }

     

    }

     

    @end

  • etresoft Level 7 Level 7 (26,870 points)

    #import "SpenceAppAppDelegate.h"

     

    @implementation SpenceAppAppDelegate;

    @synthesize textoutput;

     

    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification

    {

       int randomnumber = arc4random() % 3+1;

    }

     

    - (IBAction)button2:(id)sender

    {

        switch ([sender randomnumber])

        {

            case 1:

                textoutput.text = @"Test1";

                break;

            case 2:

                textoutput.text = @"Test2";

                break;

            case 3:

                textoutput.text = @"Test3";

                break;

            case 4:

                textoutput.text = @"Test4";

                break;

              

            default break;

        }

    }

     

    @end

  • claimsfour Level 1 Level 1 (0 points)

    Thanks,

     

    But this is what I got when I copy-pasted your corrections. 

     

    App_errors.jpg

  • etresoft Level 7 Level 7 (26,870 points)

    If I type if for you, you aren't going to learn anything. Plus I charge $200 an hour

     

    You need a colon after default.

    You can only switch on an integer.

    There is no text property in an NSTextField.

     

    After that, you have to accept the learning to program is a trial and error process. By "error" I mean 63 times in a row.

  • claimsfour Level 1 Level 1 (0 points)

    etresoft wrote:

     

    If I type if for you, you aren't going to learn anything. Plus I charge $200 an hour

     

    You need a colon after default.

    You can only switch on an integer.

    There is no text property in an NSTextField.

     

    After that, you have to accept the learning to program is a trial and error process. By "error" I mean 63 times in a row.

     

    I'm not asking you/anyone to write my apps for me. 

    Also, if anyone wants to 'steal' my code and make "millions" off of it, be my guest.

     

    I came here after I hit 'error' 64 times in a row. 

    (A solid eight hours of nonstop trial/error/tutorials/forum reads and zip/nada). 

     

    There is no text property in an NSTextField.

     

    This does not make sense (to me). However I will interpret it as 'try something different'

     

    Thanks for your insight on the colon/integer.

  • etresoft Level 7 Level 7 (26,870 points)

    claimsfour wrote:

     

    I'm not asking you/anyone to write my apps for me. 

    Also, if anyone wants to 'steal' my code and make "millions" off of it, be my guest.

     

    That was a joke, hence the smiley face.

     

    I came here after I hit 'error' 64 times in a row. 

    (A solid eight hours of nonstop trial/error/tutorials/forum reads and zip/nada). 

     

    There is no text property in an NSTextField.

     

    This does not make sense (to me). However I will interpret it as 'try something different'

     

    There is a another option in addition to trial and error - research. You might want to look at sample code too.

     

     

  • claimsfour Level 1 Level 1 (0 points)

    etresoft wrote:

     

     

    claimsfour wrote:

     

     

     

    I'm not asking you/anyone to write my apps for me. 

    Also, if anyone wants to 'steal' my code and make "millions" off of it, be my guest.

     

     

     

    That was a joke, hence the smiley face.

     

     

     

    I came here after I hit 'error' 64 times in a row. 

    (A solid eight hours of nonstop trial/error/tutorials/forum reads and zip/nada). 

     

    There is no text property in an NSTextField.

     

    This does not make sense (to me). However I will interpret it as 'try something different'

     

     

     

    There is a another option in addition to trial and error - research. You might want to look at sample code too.

     

     

     

     

    Research, books, online tutorials (Spent weeks researching before I developed the nerve to try coding)

     

    ...I once read somewhere NASA in the 50's considered

    bringing in a witch doctor to deal with their "Vanguard" program

    (Only 3 successful launches out of 11).

     

    The only thing more difficult than trying to comprehend Objective-C...are women! 

  • claimsfour Level 1 Level 1 (0 points)

    SOLUTION!!!! 

     

    These two youtube tutorials: PERFECTLY explains how to make an app.  A

    few things (like NSObject) I didn't realize fully.  These two tutorials will pretty

    much get anyone on their way to making apps.

     

    Part 1:  http://www.youtube.com/watch?v=GLxTuluYdZg

     

    Part 2: http://www.youtube.com/watch?v=CgrDSW0dHy4

     

    I FINALLY got my little app made, and it was easily one of the more

    satisfying feelings in ages. 

     

    Y'know...I might after all have a future in programming.  There is light

    at the end of the tunnel!!!!  NEVER GIVE UP!

  • claimsfour Level 1 Level 1 (0 points)

    It's never easy!

     

    I finished the app, did a 'build' and it worked perfectly on my 10.7 macbookpro.

     

    But when I sent it to my MacPro running 10.6:  IT CRASHED

     

    I then repeatedly tried in XCODE to recompile the app to work at 32bit/10.6

     

    I am now getting this error message: 

     

    Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ usr/bin/clang failed with exit code 1

     

     

    help?

  • etresoft Level 7 Level 7 (26,870 points)

    claimsfour wrote:

     

    I finished the app, did a 'build' and it worked perfectly on my 10.7 macbookpro.

     

    But when I sent it to my MacPro running 10.6:  IT CRASHED

    You've got to walk before you can run. If you must run on the 10.6 machine, you have to make sure to targen only that operating system. It will still run on Lion. If you target Lion only, it won't run on 10.6.

  • claimsfour Level 1 Level 1 (0 points)

    etresoft wrote:

     

    claimsfour wrote:

     

    I finished the app, did a 'build' and it worked perfectly on my 10.7 macbookpro.

     

    But when I sent it to my MacPro running 10.6:  IT CRASHED

    You've got to walk before you can run. If you must run on the 10.6 machine, you have to make sure to targen only that operating system. It will still run on Lion. If you target Lion only, it won't run on 10.6.

     

    More like crawl on my stomach naked over broken glass!

     

    I *finally* got a basic app running, and was able to figure out the NSString function/basic math.

     

    So now I can make a 'basic' calculator.  (which is better than a "Hello World") app.

     

    I tried the 'targeting' on my 10.7 Macbookpro to have the app output to 10.6, but I kept getting this "CLANG" error.  What in HADES is that?!?!?!?

     

    So...I rewrote the app again on my 10.6 Mac Pro, and this time it worked.

     

    There's obviously something I'm not doing right on my 10.7.  XCODE can't be that messed up on outputting a basic 10.6 app.

     

    Seems like each time I hit a small 'victory' there's about a dozen more defeats.

     

    I found drinking hard liquor helps, because you kind of lose focus...and suddenly the "ALERT/ERRORS" in Xcode will dissapear and I'll gaze at the code and go "So that's how I fixed it."

     

    That's XCODE in a nutshell,  drink hard liquor and keep bashing at

    the keyboard until the 'red/yellow' errors dissapear.

     

    Lamb's Navy Rum is great,  has a wonderully thick syrup taste to it, and mixed with Coca cola...perfecto!


    Avoid doing 'shots' because the XCODE screen will begin to look hazy and your hands will begin stumbling

    over the keyboard. Just keep the alcohol flowing into you at a steady/even rate.

  • claimsfour Level 1 Level 1 (0 points)

    XCODE 4.0.2 (On my Mac Pro 10.6.8) Deployment target:  No problem building my app for 10.6, 10.5 (I had a friend

    who still uses 10.5 run it no problem).

     

    XCODE 4.3.2 (On my MBP 10.7) When I try doing the exact same thing (adjust Deployment target):  I get a littany

    of errors/fails.

     

    Question:  How is it that I'm doing the exact same thing, and on 4.0.2. it works without a hitch, whereas

    4.3.2. I'm getting a ton of errors?

     

    Please don't tell me this is an Apple 'feature'!

Previous 1 2 Next