Re: six things I wasn't able to do with Cocoa
Re: six things I wasn't able to do with Cocoa
- Subject: Re: six things I wasn't able to do with Cocoa
- From: Alastair Houghton <email@hidden>
- Date: Fri, 28 May 2010 09:10:24 +0100
On 27 May 2010, at 20:43, Bill Appleton wrote:
> *1) I can't hide a file, or test if a file is hidden*
>
> I had to resort to FSGetCatalogInfo -- there is no way to do it through
> NSFileManager, etc. Right?
chflags(), with UF_HIDDEN? And stat() to read the same?
I don't think FSGet/SetCatalogInfo is deprecated on 64-bit though, so you could just use that if you're more comfortable doing it that way.
> *5)** **I **can't create a simple list*
>
> I did it the only way I could -- with a table that has one column, etc. Man
> that was painful for a simple list. Is there a better way?
It's not *that* painful. In fact, if you use bindings and an NSArrayController, it's pretty much done for you.
> *6)** **I **can't get the height of some wrapped text*
>
> I had to use the layout manager and some major rocket science to get this to
> work right. I'm not saying Text Edit was great, but at least it knows how
> tall the text field is.
NSAttributedString's -boundingRectWithSize:options: is probably helpful for this, depending on exactly what size you're after (there's more than one possible set of dimensions you might care about, depending on exactly what you're doing).
Cocoa Text is, I think, a bit daunting when you first encounter it; it's very powerful and exposes a great deal of the underlying machinery behind text rendering, but the flip-side of that is that it's a huge API and that alone can be off-putting. I think once you get over that, it's actually pretty easy to use---and if you're worried that it all seems a bit heavyweight to "just" draw a string, remember that most of what it does is actually necessary to get the string on the display, so all of the simpler APIs you might have used previously were still doing all of the same work (give or take).
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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