Newbie questions
Newbie questions
- Subject: Newbie questions
- From: Andy Bettis <email@hidden>
- Date: Tue, 7 Jun 2005 08:32:13 +0100
Hi folks,
My name's Andy and I'm a Mac developer ("Hi Andy!"). This is my first
visit to this forum.
I'm transitioning to Cocoa from C++/PowerPlant (and I started _way_
before the big announcement) and I have a whole bunch of questions that
aren't answered in the docs and tutorials I've been working through. A
lot of them are probably things I could work out for myself given time,
but rather than become another wheel developer surrounded by advanced
vehicle designers I thought I'd ask for some help and pointers. Any
responses gratefully received.
I'm redesigning several data classes. Some people say always subclass
NSObject, others say only do this if you really need to. My feeling
would be to use NSObject as the superclass, is this a bad idea? What
are the advantages/drawbacks/options?
A lot of my classes contain string data. With PP I would use embedded
objects (e.g. LStr255 mAddress;) in my data record classes, with
different subclasses for different data lengths (e.g. LStr31 for
strings that I knew couldn't be more that 31 characters long). I was
told that Cocoa did not use classes like this and that I would have to
hold just pointers which I would need to create and delete in the
constructor and destructor (or init and dealloc) functions. Is this
true?
Whichever way I set them up I'll end up with some sort of NSString
objects in my classes. If I can embed them they'll have to be
NSMutableStrings for updating, but if not I could use NSStrings and,
when updating them, release the original and retain the new one. Would
this be a better method (IYOs)?
As I mentioned above, I would normally use different string subclasses
depending on the maximum sizes of the data to be held in them. Do I
need to worry about sizes and storage when using NSStrings?
Another common requirement in my apps is a field to hold money values.
I would store this as a long holding the number of pennies and use
utility classes to format, read and validate it. In all the money
examples I've seen for Cocoa people just use a float and use
NSFormatter classes for UI formatting. I must admit to some trepidation
as I look at floats in the debugger and see 12.00 shown as 11.9999998,
especially as some of my supported apps have big lists of numbers to be
totalled and rounding errors are not permitted by accountants! Am I
worrying needlessly? Anyone have experience with this?
Thanks for any replies - there will be more questions, believe me.
Cheers
Rev. Andy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden