Amazon.com Widgets Exercise 2 I tried to use Program 2.3 and no go.
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 22, 2014, 05:16:20 PM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  Answers to Exercises
| | |-+  Chapter 2
| | | |-+  Exercise 2 I tried to use Program 2.3 and no go.
Pages: [1]   Go Down
Print
Author Topic: Exercise 2 I tried to use Program 2.3 and no go.  (Read 1260 times)
My2CentsWorth
Newbie
*
Posts: 49


Mark






« on: March 07, 2010, 03:17:22 PM »

Code: (Objective-C)
// First program example

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    // Simple text output for Exercise 2 at the end of Chapter2 trying to use Program example 2.3

NSLog (@"In Objective-C, lowercase leters are significant.\n
 main is where program execution begins.\n
 Open and close braces enclose program statements in a routine.\n
 All program statements must be terminated by a semicolon.");

    [pool drain];
    return 0;
}
I guess I was tying to be lazy and do it the easy way like in Program 2.3 example, I got 6 errors and 4 warnings. LOL.
I will do this the NSLog (@""); on each line way and I am sure that will work, but can someone tell me why the way I tried is wrong. I'm sure it's something pretty easy I haven"t got to yet.   Huh Thanks
Logged

Donate your unused CPU time to better the world we live in @ http://www.worldcommunitygrid.org/
My2CentsWorth
Newbie
*
Posts: 49


Mark






« Reply #1 on: March 07, 2010, 03:36:06 PM »

Code: (Objective-C)
// First program example

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    // Simple text output

NSLog (@"In Objective-C, lowercase leters are significant.");
NSLog (@"main is where program execution begins.");
NSLog (@"Open and close braces enclose program statements in a routine.");
NSLog (@"All program statements must be terminated by a semicolon.");

    [pool drain];
    return 0;
}

Code: (Objective-C)
[Session started at 2010-03-07 14:32:52 -0800.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1346) (Fri Sep 18 20:40:51 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys001
Loading program into debugger…
Program loaded.
run
[Switching to process 11197]
Running…
2010-03-07 14:32:52.409 Prog1[11197:a0f] In Objective-C, lowercase leters are significant.
2010-03-07 14:32:52.411 Prog1[11197:a0f] main is where program execution begins.
2010-03-07 14:32:52.411 Prog1[11197:a0f] Open and close braces enclose program statements in a routine.
2010-03-07 14:32:52.412 Prog1[11197:a0f] All program statements must be terminated by a semicolon.

Debugger stopped.
Program exited with status value:0.

I knew that way would work. I would like to know why the first way I tried failed tho.
Logged

Donate your unused CPU time to better the world we live in @ http://www.worldcommunitygrid.org/
My2CentsWorth
Newbie
*
Posts: 49


Mark






« Reply #2 on: March 07, 2010, 03:47:23 PM »

Code: (Objective-C)
// First program example

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    // Simple text output

NSLog (@"In Objective-C, lowercase leters are significant.\nmain is where program execution begins.\nOpenand close braces enclose program statements in a routine.\nAll program statements must be terminated by a semicolon.");

    [pool drain];
    return 0;
}

Well I figured out that it is because I hit return in my code so it looked good to me on the screen (easier to read) and in coding that must be a no no. Ok well I know not to do that again. The way I got listed here works too.
Logged

Donate your unused CPU time to better the world we live in @ http://www.worldcommunitygrid.org/
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.