• marskoko

    FIRST IMPRESSIONS: started reading apple dev center’s iPhone application programming guide (iapg), intro to objc (objc), cocoa fundamentals (cocoa) and stanford’s cs193p class. I’ve been also looking at learning C and cocoa from Scott Stevenson I think. Scotts primers in C and cocoa are very user friendly given that my background is limited to asp 2.0 and 3.0. Apples material is rather deep and so after Stevenson I focused on stanford’s class. Basically apples cocoa fundamentals in conjunction with Stanford is the best starting point in my opinion.

    Now about how all these names fit together, you need Xcode to program for cocoa. ObjC is the language and basically it has a framework called Cocoa. A framework is just a fancy way of saying that objC has been made easy to use by creating easy to use code structures in a set called Cocoa. Cocoa for mac and cocoa touch for iPhone. Furthermore cocoa for mac has a framework called foundation and application kit for mac apps and foundation/uikit for iPhone apps.

    So what does it all mean basil!? It means in my opinion you can start at the cocoa level without going crazy at the grand objC level, and easily get to cocoa touch for iPhone apps.

  • Mars

    Things ive found confusing:

    1. classes are definitions for objects. from classes, with their instance variables, we define instance methods for them. this is their behaviour. then we instantiate an object based on the class definition (inst vars and methods we created) and use those objects by sending them messages in a program. We create the class definitions in h files, explain how to implement them in m files of that class. but then the actual appdelegate m file is the actual main file where we code our main app that sends messages to the class files to instantiate objects and use them to perform functions and return results to the appdelegate file.

    a. so class h/m files should really only contain the interface and implementation of objects we need and appdelegate h/m should contain all other code?

    b. why then does the app delegate file require an h file?

    2. When we instantiate an object from a class file is when we need to allocate memory for it. we retain or copy it according to what we need it to do. i know we are supposed to deallocate it and destroy it later on. when do we really know to do so, because it seems to me that; if for example in my app that im starting with that reads an object from an array and displays it on the screen randomly whenever the user clicks the button, the array object needs to stay alive until the user closes the application, or can the objects in the array be passed on to local variables in the app delegate m file and the array objects from the class file be destroyed? which would be the more memory-efficient procedure?

    3. @property and @synthesize to generate setters and getters. What does this really mean, that the set and get properties are defined in the class? whats the advantage.

    4. initializers and custom initializers? why would you set more than one way to initialize an object.

    5. meesages to super and self? when you read if self == aObject, you are comparing WHAT exactly to aObject?

    6. i read that inst vars that hold strings should be assigned immutable NSString objects that can be replaced by setter methods. SO wait, i thought if the var was deemed immutable, it couldnt be changed?

    7. What does this mean: “Because the convention for class factory methods is to return autoreleased instances, be sure to retain the object if you wish to keep it viable in your code)

  • Mars

    In the PolygonShape.h and .m from WhatATool from Stanfords CS193 assignment, in brief they contain this:

    @implementation PolygonShape
    @synthesize its variables
    -(id) initWithNumberOfSides; “with min max number sides constraints within”
    -(id) init;
    -(void) setMinimumNumberOfSides;
    -(void) setMaximumNumberOfSides;
    -(void) setNumberOfSides;
    -(float) anglesInDegrees;
    -(float) anglesInRadians;

    This is what i understand, is this correct?
    -(id)initwithNumberOfSides is the custom init, or designated initializer for that subclass, PolygonShape. It contains within itself the sides constraints because when it is called, it uses those constraints and checks against them the arguments it is passed.

    so what is -(id)init for? and why are the constraints repeated?

Leave a Reply