Also, another alternative is to follow a singleton pattern like NSFileManager et. al and implement these as instance methods. If you do persist with either of the ObjC-based approaches, I would also suggest changing your first method to:

+ (float)systemVolume;

as this is more common Cocoa practice. The "get" prefix is generally reserved for methods that return something by reference.

Finally, it occurs to me that one possible good reason for using a singleton approach rather than anything else, is if you can make - systemVolume KVO compliant such that the user changing the system volume normally will issue a notification in your app that it has changed. Very nice for UI code to bind to.

Actually, I have a further alternative that I've just thought of. Rather than declaring your own class for these methods, you could keep them as class methods, but turn it into a category on NSSound. So you'd have:

@interface NSSound (ANSystemVolumeAdditions)

+ (float)systemVolume;
+ (void)setSystemVolume:(float)inVolume;
+ (void)increaseSystemVolumeBy:(float)amount;
+ (void)decreaseSystemVolumeBy:(float)amount;

@end

On 16 Apr 2008, at 09:35, Antonio Nunes wrote:

On Apr 16, 2008, at 9:06 AM, Jean-Daniel Dupas wrote:

I don't want to start another "Code design" war, but just wonder if doing "Utility Class" is a common practice in obj-c. Unlike Java or other object oriented language, obj-c is a superset of C and support simple functions. Wouldn't it be simpler to declare 4 functions instead of 4 class methods ?

float ANGetSystemVolume();
void ANSetSystemVolume:(float volume);

Don't know about simpler, but it's certainly a valid, and possibly more common, alternative. I don't think I have a pronounced preference for either. I'll just as happily create a functions based implementation if requested.

António

--------------------------------------------------------
Today you are You, that is truer than true.
There is no one alive who is Youer than You.
Today I am Me, and I am freer than free.
There is no one alive who is Me-er than Me.
I am the BEST I can possibly be.

--Dr. Seuss
--------------------------------------------------------


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to