Re: How can I convince an NSBigMutableString to become a mere NSAttributedString ?
Re: How can I convince an NSBigMutableString to become a mere NSAttributedString ?
- Subject: Re: How can I convince an NSBigMutableString to become a mere NSAttributedString ?
- From: Erik Stainsby <email@hidden>
- Date: Tue, 17 Jul 2012 17:31:39 -0700
Thanks for filling in my knowledge gap, Ken.
I think between what you and Dave have said, I've realised that I am trying to do too much with the object passed in to -control:isValidObject:
I was on my way to line-parsing the attributed string to determine if the user-added content is validly formatted. I think now that would be better done/ought to be done in the -control:textShouldEndEditing: which actually gives me the fieldEditor to work with.
Thanks for your time.
On 2012-07-17, at 5:20 PM, Ken Thomases <email@hidden> wrote:
> On Jul 17, 2012, at 6:58 PM, Erik Stainsby wrote:
>
>> I'm working with the text from a multiline NSTextField. When it arrives in the delegate it is represented in an NSBigMutableString.
>
> The fact that you felt compelled to investigate its actual dynamic class is a sign that you're on the wrong track. You should only rely on the documented static type.
>
>> Casting this to a NSAttributedString seems to have no effect on the actual class being used by the NSString cluster.
>
> Those are two completely different classes. An NSAttributedString *is not* an NSString or any variety thereof. It's a different thing that has-a NSString (not is-a NSString).
>
>> I can't seem to find any documentation on NSBigMutableString.
>
> That means it's private. You should not write any code which embodies any knowledge of its existence.
>
>> Can someone with deep experience tell me if I can _safely_ assume that NSBMS will respect all of NSAttributedString's method calls?
>
> No, you can't. As I said above, an NSAttributeString is not an NSString or any variety of NSString. They are not interchangeable.
>
> You can construct an NSAttributedString from an NSString, but then it won't be the same attributed string as the text field is using, so it's unlikely to be helpful. What are you actually trying to do? What delegate method are you implementing?
>
>> Also if I have a convenience function in a category, should I rewrite it as a category on NSString ? Or directly on the NSBMS, which seems to be a hidden class? Writing a category on a hidden class just doesn't feel right.
>
> You definitely shouldn't write a category on a private class. I suspect you're on the wrong path in writing a category on NSString for this situation, too.
>
> Regards,
> Ken
>
_______________________________________________
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