FROM : Ben Lachman
DATE : Wed Feb 20 21:29:17 2008
On Feb 20, 2008, at 11:56 AM, j o a r wrote:
> On Feb 20, 2008, at 5:20 PM, Jonathon Mah wrote:
>
>> I think mutable subclasses should override the convenience methods
>> of their superclass to return a mutable version. For example,
>> [NSMutableArray array] and [NSMutableString string] both return
>> mutable versions, but [NSMutableParagraphStyle
>> defaultParagraphStyle] does not. Is this considered a bug in
>> NSMutableParagraphStyle?
>
>
> The big difference between the API:s that you quote above is that
> NSMutableArray and NSMutableString returns new instances, while
> NSParagraphStyle returns a singleton, shared, instance. For this
> reason, I don't think that this could be considered a bug, or that
> it would make sense to have a similar method in
> NSMutableParagraphStyle.
While I agree that this isn't a bug, I do think it would be worth
while to have a mutable version or replacement convenience method.
In general there are a few places where cocoa is really lacking in
convenience methods and this is one of them*. I call
[[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease]
so often that I have mutableDefaultParagraphStyle defined in one of
my default categories. It just trips one up to have
NSMutableParagraphStyle return a NSParagraphStyle. I doubt (m)any
people rely on it being the actual singleton object that is returned,
particularly if they're calling it from NSMutableParagraphStyle
instead of just NSParagraphStyle.
->Ben
*others being creation of sort descriptors, attributed string and
predicates
--
Ben Lachman
Acacia Tree Software
http://acaciatreesoftware.com
<email_removed>
740.590.0009
DATE : Wed Feb 20 21:29:17 2008
On Feb 20, 2008, at 11:56 AM, j o a r wrote:
> On Feb 20, 2008, at 5:20 PM, Jonathon Mah wrote:
>
>> I think mutable subclasses should override the convenience methods
>> of their superclass to return a mutable version. For example,
>> [NSMutableArray array] and [NSMutableString string] both return
>> mutable versions, but [NSMutableParagraphStyle
>> defaultParagraphStyle] does not. Is this considered a bug in
>> NSMutableParagraphStyle?
>
>
> The big difference between the API:s that you quote above is that
> NSMutableArray and NSMutableString returns new instances, while
> NSParagraphStyle returns a singleton, shared, instance. For this
> reason, I don't think that this could be considered a bug, or that
> it would make sense to have a similar method in
> NSMutableParagraphStyle.
While I agree that this isn't a bug, I do think it would be worth
while to have a mutable version or replacement convenience method.
In general there are a few places where cocoa is really lacking in
convenience methods and this is one of them*. I call
[[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease]
so often that I have mutableDefaultParagraphStyle defined in one of
my default categories. It just trips one up to have
NSMutableParagraphStyle return a NSParagraphStyle. I doubt (m)any
people rely on it being the actual singleton object that is returned,
particularly if they're calling it from NSMutableParagraphStyle
instead of just NSParagraphStyle.
->Ben
*others being creation of sort descriptors, attributed string and
predicates
--
Ben Lachman
Acacia Tree Software
http://acaciatreesoftware.com
<email_removed>
740.590.0009
| Related mails | Author | Date |
|---|---|---|
| Jonathon Mah | Feb 20, 17:20 | |
| Nick Zitzmann | Feb 20, 17:45 | |
| Jean-Daniel Dupas | Feb 20, 17:50 | |
| j o a r | Feb 20, 17:56 | |
| Ben Lachman | Feb 20, 21:29 |






Cocoa mail archive

