"Cocoa Fundamentals Guide" Clarification
"Cocoa Fundamentals Guide" Clarification
- Subject: "Cocoa Fundamentals Guide" Clarification
- From: "Mohan Parthasarathy" <email@hidden>
- Date: Mon, 19 Jan 2009 11:00:59 -0800
Hi,
I am reading the section "Functions, Constants and Other C Types", in the
Cocoa Fundamentals Guide (
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/chapter_2_section_2.html)
and a little confused about the wording in this section.
The following list offers some guidance on using C types in the definition
of a custom class:
■ Define a function rather than a method for functionality that is often
requested but doesn't need to be
overridden by subclasses. The reason for doing this is performance. In these
cases, it's best for the function
to be private rather then being part of the class API. You can also
implement functions for behavior that
is not associated with any class (because it is global) or for operations on
simple types (C primitives or
structures). However, for global functionality it might be better―for
reasons of extensibility―to create
a class from which a singleton instance is generated.
I am slowly getting to speed on Objective C and Cocoa programming. I have
written a few classes and is all written completely in objective C. In the
classes that i have written i realize that i have a init method and at most
two other methods that are used by other objects. But there are other
methods in the classes that are mostly private i.e not used by other objects
(i relaize that all methods defined in the .h file are public). I have not
yet subclassed my own classes just the system provided classes.
Does the word private in the guide refers to the same meaning as "interfaces
that are solely used within a class and not used/extended by other "classes"
? Do i have to really care about this while writing my code or just ignore
and write everything in objective C ? If i have a chunk of code written in
"C" that i want to reuse, i guess i can do that if it is not too much of a
pain to convert to objective C. But then the word "performance" is a little
confusing in the above paragraph. Sorry, if i am reading it too
literally..Any clarification would be appreciated..
thanks
mohan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden