Previous 1 2 Next 25 Replies Latest reply: Jul 3, 2012 9:12 PM by mark133
mark133 Level 1 (65 points)

I'm confused that when a new project is added, the .m file is added with a .h file that contains an initialization. The initialization would be very helpful, except that the titles are the same for both files, so that the intermediate .h (controller) and .m (model) files are missing. Either the user should be able to add .h,.m model and .h,.m control files all at once when a project is opened (which I think is better) or else the project should open with no files, and the user can select an empty .h or .m file to start building the project.

  • mark133 Level 1 (65 points)

    Or both.

  • red_menace Level 6 (15,000 points)

    Not quite sure what you are referring to, but .h is a header file and .m is a class implementation file.  If you are talking about a Cocoa application, the AppDelegate files are the minimum to get the application started; anything else depends on what is needed for the particular application.  You can copy and tweak one of the project templates to add a few more default classes if you are feeling frisky.

  • mark133 Level 1 (65 points)

    I see Cocoa as about half-way completed. Whenever I run into a major stumbling block, I try to document the solution I see as a beginner, in hopes that someone will pick it up and run with it.


    As you exemplify, you are proficient at scripting, and almost able to deal with Objective-C. You refer to copying and tweaking files to get what you want. To make Cocoa a more popular platform, the need to do some 'tweaking' to make it work right is a challenge that needs to be addressed and resolved.


    You are clearly competent to such a degree that Cocoa should be a joy for you to use, but even you will admit that objective-C is a pain.


    I can see where too much Cocoa is a bad thing, but the project is only half baked, and if completed, it would really be a tremendous social asset.

  • red_menace Level 6 (15,000 points)

    Cocoa and Objective-C are going to be running me around for quite a while longer.  The included templates are just some plain vanilla projects - to get the cherries and chocolate shavings in there you usually have to add them yourself.  I suspect that most of the more serious programmers around here use their own project templates, code snippets, custom build phases, and behaviors to make new projects easier.

  • mark133 Level 1 (65 points)

    I couldn't agree more. Cocoa is not at all what it could be. But it is so promising, I really hope some people at Apple are taking it up.


    The Interface Builder is Practically complete. I think it went funny when they started trying to do a 'control builder' and a 'model builder' in the same way as the 'Interface Builder'.


    Instead, the model and control should be done as one unit. Maybe where the user 1) enters data types and their variable names to be stored and/or manipulated, 2)enters main functions for the data 3)enters variable names for the available Views actions/outlets 4)enters functions that combine the view variable and the main function and main data variables.


    Then the model .h .m and controller .h .m file templates could all be generated at once, with beginning instructions on how they could be manipulated according to the class.

  • red_menace Level 6 (15,000 points)

    That sounds a lot like using class libraries or frameworks, although at some point you are going to have to do the actual programming - Skynet is still a ways off (I hope).  Now you know why it takes years to get fluent with this stuff, although I might have better luck learning Japanese.

  • mark133 Level 1 (65 points)

    I do a lot of over-thinking, so maybe that's the case. Here is how I'm seeing it at this point, anyway:

    Objective C.png


    Then, with the variable name for naming a variable, it would look like this:



  • mark133 Level 1 (65 points)

    I messed up on the naming conventions, I have to read that section a few more times.

  • red_menace Level 6 (15,000 points)

    I can't quite make out what your class examples are supposed to do, but it looks like classes and the instances of those classes are mixed together (you might still be thinking in procedural terms).  If I am understanding correctly, you have an equation class that describes how the equations are built, and a data object class which describes the objects used in the equations.

  • mark133 Level 1 (65 points)

    Right now, I'm just trying to get a good general approach to understanding and working with Objective-C.

  • mark133 Level 1 (65 points)

    The object is declared in the interface, but the instance is 'declared' in the implementation?

  • red_menace Level 6 (15,000 points)

    Yes - the interface provides a description of what the class can do, and the implementation implements the methods defined in the interface.  An object would be a concrete instance of a class, for example created via [[SomeClass alloc] init] or [SomeClass new].

  • mark133 Level 1 (65 points)

    Doesn't the interface just really only provide the external objects(i.e. classes) and data that are going to be used in the implementation, and gives them names?


    Doesn't the implementation really tell what the class is able to do?


    Then it takes another, external class, to declare the .h,.m object(the class) in it's interface, and give a name to it as well as whatever other objects and data will be used by itself.


    Then the implementation of this second class can create and instance, allocating and initializing the first class.


    So it takes four files, Class I .h,.m and Class II .h,.m to understand what classes are and how they are used?

  • mark133 Level 1 (65 points)

    So it's like:


    Class A                               ClassB


    .h                                       #import Class A.h


    NSObj myobject;                 Class classInstance

    int Answer                           int GetAnswer

                                              int NewAnswer

    .m                                      .m


    -Answer                              -GetAnswer                          

    {myobject+5;}                       {classInstance=[[Class alloc]init];

                                              NewAnswer= [classInstance Answer]+8;}

Previous 1 2 Next