Data Types and Expressions.

Discussion in 'iOS Programming' started by RobertD63, Feb 3, 2010.

  1. RobertD63 macrumors 6502

    Joined:
    Feb 17, 2008
    Location:
    A place
    #1
    Okay I'm about to dive into this chapter about Data Types and Expressions. Back when I was trying Obj-c about 7 months ago I got to this chapter and it was pretty hard for me to grasp these concepts. So do you guys have any tips for me?
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    1. Ask specific questions.

    1b. If you're asking a question about something in a specific book, give the author, title, and version of the book. If the problem is with a specific passage or sentence in the book, then quote that specific passage or sentence, rather than paraphrasing it.

    2. Don't expect anyone to remember what you did (or posted about) 6 months ago. Or one month ago. Or even one week ago, if it's on a high-traffic forum.

    3. http://www.mikeash.com/getting_answers.html
     
  3. RobertD63 thread starter macrumors 6502

    Joined:
    Feb 17, 2008
    Location:
    A place
    #3
    1. I was asking for any kind of tips that helped you guys learn Data Types and Expressions.
    1b. I dont have any problems with the book, actually I love it.
    2. I wasn't asking anyone to "remember" what I did or posted back then. I actually said nothing about that, I was just giving a backlog that i've tried to learn it before and it was extremely hard for me.
    3. Thank you for being so kind...

    So to be more specific I was wondering when you guys learned how did you get through this?
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    Everyone is different. Some people understand data types and expressions right away. Other people have difficulty, but with different things. If you don't explain what you found hard, or why you stopped before, there really aren't any tips other than the ones I already gave.

    I wasn't suggesting the book was bad (or good). I was simply pointing out that you hadn't identified the book, so there's no way for anyone else to tell you whether the chapter on data types and expressions might be harder or easier to understand than some other book. There's also no way to suggest a complementary book that might give better explanations in this case. You also didn't explain why you found the explanations in the book hard, whether it's lack of background, unfamiliar terms, or whatever.

    One example of a difficulty: a guy I worked with was learning C. He came from a mathematics background, so already understood arithmetic expressions, complex calculations, iterative algorithms, number theory, etc. but had never learned any programming language. In one of his programs, he declared some variables as type 'float', then used them as subscripts for C arrays. This didn't work. When he asked me why, I told him that subscripts have to be integers. He assured me they were in fact integers, and sure enough, the values of the variables were integers (0.0, 1.0, 4.0, etc.). I then explained to him that it didn't just have to be an integer number, but the type had to be an integer type. That lead into an explanation of binary numeric representations, especially the difference between the integer types and the floating-point types. He had a specific difficulty (float types used as array subscripts), that took a specific explanation to resolve (numeric representations).
     
  5. RobertD63 thread starter macrumors 6502

    Joined:
    Feb 17, 2008
    Location:
    A place
    #5
    Ah okay makes plenty sense now, sorry bout that. The book I'm reading is
    Programming in Objective-C 2.0 by Stephen G. Kochan. What I dont understand is here:

    So does this mean that any thing that I typed out in lets say NSLog is a constant character string object?
     
  6. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #6
    No, not any thing, only the things that are string objects.
    Not everything is a string.
    Not everything is an object, either.


    Examples:

    Code:
    NSLog( @"%d", 27 );
    
    The @"%d" is a constant character string object. The 27 is a constant integer value: it's constant, but it's neither a string nor an object.

    Code:
    NSLog( @"%f", 355.0/113.0 );
    
    The @"%f" is a constant character string object. The 355.0/113.0 is a constant floating-point expression: it has a constant numeric value, but that value is not an integer, nor a string, nor an object.

    Code:
    NSLog( @"%c %c", '6', 'c'+1 );
    
    The @"%s" is a constant character string object. The '6' is a constant character (a single digit), and the 'c'+1 is a constant character expression: they are single characters, not strings. The expression 'c'+1 essentially means the character that is 1 more than 'c' in the character set.

    Code:
    NSLog( @"%s", "xyzzy" );
    
    The @"%s" is a constant character string object. The "xyzzy" is a constant C string: it's a constant string, but it isn't an object.

    Code:
    NSLog( @"%@", @"foo" );
    
    The @"%@" and @"foo" are both constant character string objects. That is, they are both character strings, and they are both objects.
     

Share This Page