To run a block of code at every 1 second

2009-03-03 Thread Stuart Malin
On Mar 3, 2009, at 7:24 AM, cocoa-dev-requ...@lists.apple.com wrote: the following method is running in a separate thread: - (void)myFucntion { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; for (;;)// for loop starts here and is very quick, 100s of iterations per

Re: Checking for NULL (was "Re: Can't get setDelegate to work...")

2009-03-04 Thread Stuart Malin
On Mar 4, 2009, at 12:15 PM, cocoa-dev-requ...@lists.apple.com wrote: In any case, and perhaps based purely on habit, I find it difficult to even write: NSStatusItem statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain];

NSPopUPButton and selectedTag binding seems to give me index instead

2009-03-05 Thread Stuart Malin
I have a NSPopUpButton that is driven by bindings. I establish (programmatically) a binding between the NSPopUpButtom instance's "selectedTag" property and an NSTreeController that contains objects that have a property that should correspond with the available tag values. This does not seem

When to release an NSThread instance

2009-03-06 Thread Stuart Malin
I have a main thread method that allocates an NSThread object and inits with initWithTarget:selector:object. I then invoke the NSTask instance with -start. The specified selector is invoked, and there performs a background task that takes some time. When it is done, that method invokes a

Can an object observe itself?

2009-03-07 Thread Stuart Malin
I have a model class with multiple properties. I need to know in a variety of places when certain of these change. Presently, the model objects can be changed by an inspector that has bindings to the model instances, which are managed as a collection by an NSArrayController. So... I tried a

[SOLVED} Re: Can an object observe itself?

2009-03-07 Thread Stuart Malin
Oops, found my problem... the model class is NSCoding compliant and so objects can also be initialized via -initWithCoder, and I needed to add the observer there as well. On Mar 7, 2009, at 10:31 AM, Stuart Malin wrote: I have a model class with multiple properties. I need to know in a

Re: Can an object observe itself?

2009-03-07 Thread Stuart Malin
On Mar 7, 2009, at 11:18 AM, Keary Suska wrote: On Mar 7, 2009, at 1:31 PM, Stuart Malin wrote: I have a model class with multiple properties. I need to know in a variety of places when certain of these change. Presently, the model objects can be changed by an inspector that has bindings

NSArrayController -- will change selection?

2009-03-07 Thread Stuart Malin
I've got a preferences view that is a kin to Mail's for its accounts, and I'd like it to behave the same. I am using an NSArrayController to manage a table list of accounts. There are a variety of account datum presented in NSTextFields. These fields are bound to the controller. I am able t

[SOLVED] Re: NSArrayController -- will change selection?

2009-03-07 Thread Stuart Malin
Exactly what I need! Many thanks for responding. Can't believe I was acting as if having the array controller and a delegate were mutually exclusive. On Mar 7, 2009, at 3:12 PM, Kyle Sluder wrote: Wire up an object as your table view's delegate and implement -tableView:shouldSelectRow:. -

Re: [SOLVED] Re: NSArrayController -- will change selection?

2009-03-07 Thread Stuart Malin
On Mar 7, 2009, at 3:42 PM, Kyle Sluder wrote: Just be careful to cover all other methods by which the user can potentially lose data. No longer is your controller responding to a change in the selected model object, but instead to a change in the selected row in the view. It's unfortunate, bu

Re: [SOLVED] Re: NSArrayController -- will change selection?

2009-03-07 Thread Stuart Malin
On Mar 7, 2009, at 3:57 PM, Kyle Sluder wrote: On Sat, Mar 7, 2009 at 8:55 PM, Stuart Malin wrote: Those are the only three means I am aware of (selection, window close, view change) that can potentially lead to loss of user data. Any others? Add and remove. You'd probably wa

Re: NSArrayController -- will change selection? --> tableView shouldSelectRow invoked twice

2009-03-07 Thread Stuart Malin
On Mar 7, 2009, at 3:12 PM, Kyle Sluder wrote: Wire up an object as your table view's delegate and implement -tableView:shouldSelectRow:. This delegate is being invoked twice. Is that ordinary and usual behavior? I found a post about this, made in 2005. Corbin Dunn replied that it was a

problem observing selectionIndex of an array controller

2009-03-07 Thread Stuart Malin
I'm trying to watch for changes in the selection of a tableView managed by an NSArrayController. I set up an observer: [mArrayController addObserver:self forKeyPath:@"selectionIndex" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew

Re: problem observing selectionIndex of an array controller

2009-03-08 Thread Stuart Malin
On Mar 7, 2009, at 10:10 PM, Ken Thomases wrote: On Mar 8, 2009, at 1:52 AM, Stuart Malin wrote: I'm trying to watch for changes in the selection of a tableView managed by an NSArrayController. I set up an observer: [mArrayController addObserver:self forKe

How to intercept NSToolbar item selection changes

2009-03-08 Thread Stuart Malin
I'm building a Preferences window that has a toolbar, in the style of Mail. I need to know if the user clicks on a toolbar item to change the pane. If the current pane has pending changes, I display a sheet asking for action regarding the present changes. I need to do this BEFORE the select

Re: How to intercept NSToolbar item selection changes

2009-03-09 Thread Stuart Malin
On Mar 9, 2009, at 3:46 AM, cocoa-dev-requ...@lists.apple.com wrote: On Sun, Mar 8, 2009 at 6:03 PM, Stuart Malin wrote: I'm building a Preferences window that has a toolbar, in the style of Mail. I need to know if the user clicks on a toolbar item to change the pane. If the current

Re: How to intercept NSToolbar item selection changes

2009-03-09 Thread Stuart Malin
On Mar 9, 2009, at 8:47 AM, Michael Ash wrote: On Mon, Mar 9, 2009 at 12:38 PM, Stuart Malin wrote: On Mar 9, 2009, at 3:46 AM, cocoa-dev-requ...@lists.apple.com wrote: Could you simply reset the toolbar selection to whatever it was before, then display your sheet and then manually set

Re: [SOLVED] Re: NSArrayController -- will change selection?

2009-03-10 Thread Stuart Malin
On Mar 7, 2009, at 3:57 PM, Kyle Sluder wrote: On Sat, Mar 7, 2009 at 8:55 PM, Stuart Malin wrote: Those are the only three means I am aware of (selection, window close, view change) that can potentially lead to loss of user data. Any others? Add and remove. You'd probably wa

Is it possible to make the height of an NSSegmentedControl taller?

2009-03-11 Thread Stuart Malin
I am using an NSSegmentedControl in a toolbar to hold some mutually exclusive selections. I invoke -setImage:forSegment: to set an image for each, but the images are taller than the height of the segments. I don't seem to have any control over that height with the NSRect I use to init the

Is cascading Nib Loading from -awakeFromNib permissible?

2009-03-11 Thread Stuart Malin
In my MainMenu Nib I have a controller object. The code for that controller object has an -awakeFromNib method. That method invokes NSBundle's -loadNibNamed: method to load yet another Nib. Doing this leads to repeating invocations of the -awakeFromNib method of the initial controller (it i

Re: Is cascading Nib Loading from -awakeFromNib permissible?

2009-03-11 Thread Stuart Malin
On Mar 11, 2009, at 12:37 PM, Dave Keck wrote: It looks like this is your answer: http://lists.apple.com/archives/cocoa-dev/2008/Apr/msg02276.html It sounds like the object is the file's owner of the nibs that you're loading using loadNibNamed:. Is this correct? Also check out: http://www.go

Re: Is cascading Nib Loading from -awakeFromNib permissible?

2009-03-11 Thread Stuart Malin
On Mar 11, 2009, at 1:03 PM, Ken Thomases wrote: On Mar 11, 2009, at 5:49 PM, Stuart Malin wrote: I am getting infinite calls, not double calls. It sounds to me like you're getting double calls and you're turning them into infinite calls. If you load a nib inside of - awakeFr

Re: Is cascading Nib Loading from -awakeFromNib permissible?

2009-03-12 Thread Stuart Malin
On Mar 11, 2009, at 1:37 PM, Stuart Malin wrote: Further, the second Nib I am loading has no references back to the controller, except as File's Owner. And that's enough to get awakeFromNib'd. Interesting -- there must be some further distinctions here. I have another

Re: Binding to selection of NSArrayController manually

2009-03-13 Thread Stuart Malin
On Mar 13, 2009, at 9:42 AM, Ivy Feraco wrote: I have an NSArrayController subclass and an NSPopUpButton subclass. I am trying to bind the NSPopUpButton's selected object to the selection of my array controller. I have to do this manually for reasons I won't get into here. But when I do this (

Re: case-insensitive NSDictionary

2009-03-16 Thread Stuart Malin
On Mar 16, 2009, at 7:55 AM, Sherm Pendley wrote: On Mon, Mar 16, 2009 at 12:03 PM, Michael Ash wrote: Why does everybody think that subclassing a class cluster is hard? Beats me - I've often wondered the same thing. All you need to do is implement the required primitive methods. W

[noob] Best practice for creating multiple instances of a View

2009-03-20 Thread Stuart Malin
I have a Nib file containing a single NSView that contains several controls. I need to make numerous copies of this view (which are placed as subviews of some containing view). Presently, I load the Nib for each occurrence needed. But I now wonder if this is the best approach (going back to

Re: [noob] Best practice for creating multiple instances of a View

2009-03-20 Thread Stuart Malin
On Mar 20, 2009, at 8:38 AM, I. Savant wrote: On Fri, Mar 20, 2009 at 2:19 PM, Stuart Malin wrote: I have a Nib file containing a single NSView that contains several controls. I need to make numerous copies of this view (which are placed as subviews of some containing view). Presently, I

Re: [noob] Best practice for creating multiple instances of a View

2009-03-20 Thread Stuart Malin
On Mar 20, 2009, at 9:30 AM, I. Savant wrote: On Fri, Mar 20, 2009 at 2:53 PM, Stuart Malin wrote: Thanks for the quick reply and the assurance. No performance issues -- just had been wondering about the effect of going back to disk every time I need one of these views (which will be

Re: [noob] Best practice for creating multiple instances of a View

2009-03-20 Thread Stuart Malin
On Mar 20, 2009, at 10:09 AM, mmalc Crawford wrote: Modulo other's comments about premature optimisation, if you want to avoid going back to the disk:

[SOLVED] Re: [noob] Best practice for creating multiple instances of a View

2009-03-22 Thread Stuart Malin
On Mar 20, 2009, at 11:08 AM, Stuart Malin wrote: On Mar 20, 2009, at 10:09 AM, mmalc Crawford wrote: Modulo other's comments about premature optimisation, if you want to avoid going back to the disk: <http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/ApplicationKit

Can NSTrackingArea rects be nested?

2009-03-27 Thread Stuart Malin
I have a view that contains an NSTextView. I place NSTrackingAreas on portions of the TextView's text. I attach a userInfo dictionary to each of the tracking areas with a variety of parameters. The view containing the TextView happens also to have an NSTrackingArea around its entire frame.

[SOLVED] Re: Can NSTrackingArea rects be nested?

2009-03-28 Thread Stuart Malin
On Mar 28, 2009, at 2:31 AM, Quincey Morris wrote: On Mar 27, 2009, at 15:48, Stuart Malin wrote: I have a view that contains an NSTextView. I place NSTrackingAreas on portions of the TextView's text. I attach a userInfo dictionary to each of the tracking areas with a variety of param

[NSView noob] How to be detect when a scroll view scrolls its document view

2009-03-31 Thread Stuart Malin
I have an NSScrollView with a document view that contains many subviews. I need to perform some processing on these views as they become visible or not visible because of scrolling of the ScrollView. I'm sure this must be straightforward to detect, but alas, I don't have a deep enough under

Seeking advice on best practice for managing visibility of many subviews

2009-04-01 Thread Stuart Malin
I have a view that has hundreds of subviews. The user can control filters which causes different of the subviews to be presented; the collection of selected-for-presentation subviews are repositioned in the super view. I can think of two ways to handle this, and am not sure which is best: 1

Re: Seeking advice on best practice for managing visibility of many subviews

2009-04-02 Thread Stuart Malin
On Apr 1, 2009, at 10:54 PM, Alexander Spohr wrote: Am 02.04.2009 um 04:47 schrieb Stuart Malin: I have a view that has hundreds of subviews. This sounds like a conceptual error. You could make something like cells instead of views, to avoid the NSView overhead. Arrange them in groups

Re: Beachball on Lengthy Task

2009-04-04 Thread Stuart Malin
On Apr 4, 2009, at 5:07 PM, Andrew Farmer wrote: On 04 Apr 09, at 19:35, Pierce Freeman wrote: Yeah, it really helped! I am trying to get the contents of the files in a certain directory, so I think that I could probably get away with using a timer. I assume you mean NSTimer for the timer, t

Re: Beachball on Lengthy Task

2009-04-04 Thread Stuart Malin
On Apr 4, 2009, at 5:36 PM, Pierce Freeman wrote: And, if you are 10.5 only, there's also NSObject's performSelectorInBackground:withObject: Is this a timer or a thread creator? I don't believe it has inputs for the time, or could it just do it automatically? Also, is there some way I c

NSString and decoding HTML Entities

2009-04-05 Thread Stuart Malin
I need to convert strings that contain HTML entities (e.g., ’ or &#gt;). I can't seem to find an NSString method to do so (not that I sometimes don't easily miss the obvious). So, I created a category on NSString and made two trivial methods that take advantage of toll- free bridging betw

Re: NSString and decoding

2009-04-05 Thread Stuart Malin
On Apr 5, 2009, at 10:22 AM, Jack Carbaugh wrote: it would have helped if I read & digested the WHOLE message. my apologies ! what i referenced and what he wanted were two different things. my apologies, jack no worries. this notion of escaping HTML entities seems often confused with U

Re: NSString and decoding HTML Entities

2009-04-05 Thread Stuart Malin
On Apr 5, 2009, at 10:19 AM, I. Savant wrote: On Apr 5, 2009, at 3:56 PM, Stuart Malin wrote: I need to convert strings that contain HTML entities (e.g., ’ or &#gt;). To what? If you want it to be an attributed string, there's always the - [NSAttributedString ini

Re: NSString and decoding HTML Entities

2009-04-05 Thread Stuart Malin
On Apr 5, 2009, at 11:32 AM, I. Savant wrote: On Apr 5, 2009, at 4:35 PM, Stuart Malin wrote: The source is not HTML tagged, but contains HTML entities. see: http://www.w3schools.com/tags/ref_entities.asp http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references So

initializer for NSTextView subclass not being invoked on Nib instantiation

2009-04-08 Thread Stuart Malin
I have a Nib with a single custom NSView subclass. That view has some controls in it, including an instance of an NSTextView (that is also subclassed). When the Nib is instantiated, the -awakeFromNib method of the MyTextView class is invoked, but neither -initWithFrame: nor - initWithFrame

Re: initializer for NSTextView subclass not being invoked on Nib instantiation

2009-04-08 Thread Stuart Malin
/LoadingResources/CocoaNibs/CocoaNibs.html#/ /apple_ref/doc/uid/1051i-CH4-SW19 You're using awakeFromNib for its intended purpose. Good Luck - Jon Hess On Apr 8, 2009, at 1:15 AM, Stuart Malin wrote: I have a Nib with a single custom NSView subclass. That view has some controls in it, includi

Re: initializer for NSTextView subclass not being invoked on Nib instantiation

2009-04-08 Thread Stuart Malin
Great explanation, Kyle. Thanks for taking the effort to provide one so thorough. On Apr 7, 2009, at 10:28 PM, Kyle Sluder wrote: On Wed, Apr 8, 2009 at 4:15 AM, Stuart Malin wrote: Googling this issue has led me to discover that, for NSTextView, -initWithCoder gets called instead. Yes

Re: how to load an NSMenu out of a nib?

2009-04-08 Thread Stuart Malin
On Apr 8, 2009, at 2:10 PM, Peter Ammon wrote: On Apr 8, 2009, at 2:47 PM, Rua Haszard Morris wrote: I'm baffled, this seems fundamental, I can't see how it's done! I have a Menu in a nib file, which I need to use in a few places in code. So I want to do something like NSMenu* myMenu = [NSM

Best practice regarding display of many similar items in a lengthy view

2009-04-23 Thread Stuart Malin
I am building an app that displays a list of "composite" items. By composite I mean that each item has multiple clickable icons, images, and multiple bits of text. In my first implementation, I modeled these items with a Nib containing a custom NSView and a variety of IB installed sub views

NSTableView variable row height and noteHeightOfRowsWithIndexesChanged during live resize

2009-04-23 Thread Stuart Malin
I have an NSTableView with a single column that has a custom cell. During a live resize, I recalculate the row height in the delegate method -tableView:heightForRow: and return the result. However, some rows don't grow larger. I presume I need to call the tableview's - noteHeightOfRowsWithIn

Re: NSTableView variable row height and noteHeightOfRowsWithIndexesChanged during live resize

2009-04-23 Thread Stuart Malin
On Apr 23, 2009, at 12:33 PM, Corbin Dunn wrote: On Apr 23, 2009, at 2:55 PM, Stuart Malin wrote: I have an NSTableView with a single column that has a custom cell. During a live resize, I recalculate the row height in the delegate method -tableView:heightForRow: and return the result

Re: NSTableView variable row height and noteHeightOfRowsWithIndexesChanged during live resize

2009-04-23 Thread Stuart Malin
On Apr 23, 2009, at 1:18 PM, Corbin Dunn wrote: On Apr 23, 2009, at 3:37 PM, Stuart Malin wrote: On Apr 23, 2009, at 12:33 PM, Corbin Dunn wrote: On Apr 23, 2009, at 2:55 PM, Stuart Malin wrote: I have an NSTableView with a single column that has a custom cell. During a live resize

problems with live resize of NSTextView

2009-04-24 Thread Stuart Malin
I have an NSTextView in a custom view, it is set to resize with the containing view only in the horizontal dimension. When I resize the window, the text view does resize, and it does re-layout its content to fit, both on expanding and shrinking. However, the text view not only changes its f

Re: problems with live resize of NSTextView

2009-04-25 Thread Stuart Malin
On Apr 25, 2009, at 5:08 AM, Keary Suska wrote: On Apr 24, 2009, at 3:06 PM, Stuart Malin wrote: I have an NSTextView in a custom view, it is set to resize with the containing view only in the horizontal dimension. When I resize the window, the text view does resize, and it does re

Re: problems with live resize of NSTextView

2009-04-25 Thread Stuart Malin
On Apr 25, 2009, at 9:17 AM, Keary Suska wrote: On Apr 25, 2009, at 12:05 PM, Stuart Malin wrote: On Apr 25, 2009, at 5:08 AM, Keary Suska wrote: On Apr 24, 2009, at 3:06 PM, Stuart Malin wrote: I have an NSTextView in a custom view, it is set to resize with the containing view only in

Re: catching whitespace with scanner

2009-05-06 Thread Stuart Malin
On May 6, 2009, at 7:08 PM, Daniel Child wrote: I'm trying to catch whitespace between words with a scanner. For some reason, the white space is not being recognized. Am I missing something obvious or is there a bug here? Thanks. NSScanner defaults to skipping whitespace and newlines. Try ad

Key-Value Observing: light-weight or heavy-weight?

2009-05-07 Thread Stuart Malin
I've got a situation where I have several hundred objects of a class that have a KVC-compliant property. There are a matching set of other objects that refer to the former. For a problem I need to solve, one solution is for the other objects to observe the property of their counterpart obje

Getting "Unknown class 'someClassName' in nib file" message

2009-05-13 Thread Stuart Malin
I have tried both Google and searching the archives regarding the problem with the subject message, but can only find cases where someone has a class and didn't include it. My case is different: in my project, I renamed a class. I have made appropriate changes in both Xcode and IB for this

Re: Getting "Unknown class 'someClassName' in nib file" message

2009-05-13 Thread Stuart Malin
issuing the log message. Jon Hess On May 13, 2009, at 1:15 PM, Stuart Malin wrote: I have tried both Google and searching the archives regarding the problem with the subject message, but can only find cases where someone has a class and didn't include it. My case is different: in my projec

Bindings and KVO of View objects

2009-05-19 Thread Stuart Malin
As my understanding of Bindings is that they implement using KVO and KVC, then is it safe to assume that if an object has a bindable property, then that property should be observable with KVO, yes? My specific concern is with NSSegmentedControl, which has a bindable property "selectedIndex"

Re: Bindings and KVO of View objects

2009-05-19 Thread Stuart Malin
On May 19, 2009, at 1:44 PM, Kyle Sluder wrote: On Tue, May 19, 2009 at 7:01 PM, Quincey Morris wrote: On May 19, 2009, at 14:18, Stuart Malin wrote: No. The name of the binding is *not* the same as the name of any property of the bound object. For example, most controls have a "

Re: Bindings and KVO of View objects

2009-05-19 Thread Stuart Malin
On May 19, 2009, at 1:44 PM, Quincey Morris wrote: On May 19, 2009, at 14:18, Stuart Malin wrote: My specific concern is with NSSegmentedControl, which has a bindable property "selectedIndex". I am trying to add an observer for this property (using -addObserver: on an instance).

Re: Bindings and KVO of View objects

2009-05-20 Thread Stuart Malin
On May 20, 2009, at 1:04 AM, Quincey Morris wrote: On May 19, 2009, at 17:22, Stuart Malin wrote: I don't see why it is a design flaw to want to bind to the selectedIndex of a segmented control so that when the user changes the selected segment, my code to take action. Binding to the co

<    1   2