Lazy calculation of tooltip text

2018-07-06 Thread Jonathan Taylor
I have a UI item (text field) that displays a tooltip when the user hovers over it. However, the information to be displayed in the tooltip is dynamic and relatively expensive to compute. At the moment the tooltip is bound to a string property which I manually update twice a second. It seems tha

Re: Property in class mirrored to user defaults

2017-06-16 Thread Jonathan Taylor
2 Jun 2017, at 16:01, Charles Srstka wrote: >> On Jun 12, 2017, at 4:04 AM, Jonathan Taylor >> wrote: >> >> Hi all, >> >> This feels like a very basic question, but one that I have not had any luck >> searching for (maybe I am using the wrong terms

Property in class mirrored to user defaults

2017-06-12 Thread Jonathan Taylor
Hi all, This feels like a very basic question, but one that I have not had any luck searching for (maybe I am using the wrong terms?). At the moment I have properties in a (singleton) class that are bound to UI elements. At the moment they have the same automatic values every time the app is l

Re: Relative URLs, and string encodings

2017-06-02 Thread Jonathan Taylor
>> My attempt like: >> [NSURL URLWithString:[path >> stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding] >> relativeToURL:relativeTo]; > > Ah, you want NSUTF8StringEncoding instead. Generally speaking, URL encoding > always uses UTF-8 nowadays. Thankyou for your reply Jens. That's

Relative URLs, and string encodings

2017-06-01 Thread Jonathan Taylor
Can anyone help me with the seemingly simple task of creating a relative NSURL for a filesystem object? The catch here (sorry!) is that I really do need backward compatibility to 10.7, which rules out fileURLWithFileSystemRepresentation:isDirectory:relativeToURL: (which I suspect is the “right”

Re: Prioritizing drawing of the important stuff

2016-11-01 Thread Jonathan Taylor
Hi everyone, Thankyou all for your replies. Plenty of food for thought there - much appreciated. Looks like timers and flow control is the way forward then, if I want to tackle this. I just thought I'd see if there was anything built in to the standard UI frameworks that might be able to help,

Re: Prioritizing drawing of the important stuff

2016-10-29 Thread Jonathan Taylor
0sec elapsed > time whenever the slider is updated, and if it reaches a small delay then the > HQ image is rendered (and remains on-screen until the slider is later moved > and the process repeats). No need to rely on GCD or threading. > > — Slipp > >> On Oct 29, 20

Re: Prioritizing drawing of the important stuff

2016-10-29 Thread Jonathan Taylor
parency based on its size that might be helpful. > > So, I think I am saying this problem is not new and has been addressed in > several different ways in the NSView class. > > >> On Oct 29, 2016, at 2:37 AM, Jonathan Taylor >> wrote: >> >> Hi all, >>

Prioritizing drawing of the important stuff

2016-10-29 Thread Jonathan Taylor
Hi all, This is a bit of a general question, but hopefully people may have some suggestions. I've got some drawing code that synthesizes an image in a window, which will change in response to sliders (e.g. changing the camera perspective). My problem is how to make it so that the redrawing of t

Re: Mixed-state checkboxes

2016-07-08 Thread Jonathan Taylor
ing altogether and just set the actual state of the UI element directly from my code. I'd definitely be interested in understanding what it sounded like you were suggesting with a "basically read-only" binding though... Cheers Jonny On 8 Jul 2016, at 18:35, Quincey Morris wro

Mixed-state checkboxes

2016-07-08 Thread Jonathan Taylor
Hi all, I'm trying to work out the correct way to handle a mixed-state checkbox (NSButton checkbox with allowsMixedState=YES), bound to a property on my controller. I am intending it to serve as an "applies to all" type control at the head of a column of checkboxes - so if other checkboxes in t

Re: Prioritize my own app's disk access

2016-07-06 Thread Jonathan Taylor
On 6 Jul 2016, at 18:01, Quincey Morris wrote: > On Jul 6, 2016, at 03:06 , Jonathan Taylor > wrote: >> >> a single lost frame will be fairly catastrophic for the scientific experiment > > If this is genuinely your scenario, then nothing mentioned in this thread is

Re: Prioritize my own app's disk access

2016-07-06 Thread Jonathan Taylor
Thanks for your reply Alastair. Definitely interested in thinking about your suggestions - some responses below that will hopefully help clarify: > The first thing to state is that you *can’t* write code of this type with the > attitude that “dropping frames is not an option”. Fundamentally, th

Re: Prioritize my own app's disk access

2016-07-05 Thread Jonathan Taylor
Thanks everyone for your replies on this second question of mine. Some responses below: On 5 Jul 2016, at 18:20, Quincey Morris wrote: > What worries me about the Darwin-level (i.e. Unix-level) API suggestions that > others have made is that you don’t know how these interact with Cocoa apps.

Re: Property synthesis trouble - 32 vs 64 bit builds

2016-07-05 Thread Jonathan Taylor
On 5 Jul 2016, at 22:22, "Gary L. Wade" wrote: > You might need to write some lower level stuff, but some of the things in > there can be done, albeit differently. Apple knows I've submitted a number of > bugs and incident reports to get codecs supported in later frameworks. Do the > same. It m

Re: Property synthesis trouble - 32 vs 64 bit builds

2016-07-05 Thread Jonathan Taylor
>> Quicktime. > > Oh, you poor thing. That’s one nasty API. (Actually dozens of nasty APIs.) O_o Yep. I rely on code that I worked out years ago, with the help of examples on the internet, and I do my best to leave that code untouched! >> My code has been 32-bit only since I first wrote it, bec

Re: Property synthesis trouble - 32 vs 64 bit builds

2016-07-05 Thread Jonathan Taylor
Thanks everyone for your replies - some responses below: On 5 Jul 2016, at 20:55, Greg Parker wrote: > A synthesized property must use one of the following types of storage: > 1. An ivar in that class that @synthesize creates. > 2. An ivar in that class that you defined yourself. > > @synthesize

Re: Property synthesis trouble - 32 vs 64 bit builds

2016-07-05 Thread Jonathan Taylor
that by writing explicit setters/getters, so I will do that. (*) there are rather a lot of these properties in the actual original code, but it just involves a lot of typing! On 5 Jul 2016, at 16:12, Keary Suska wrote: > >> On Jul 5, 2016, at 5:36 AM, Jonathan Taylor >> wrote

Re: Prioritize my own app's disk access

2016-07-05 Thread Jonathan Taylor
Jul 2016, at 13:36, Jonathan Taylor > wrote: >> >> This is a long shot, but I thought I would ask in case an API exists to do >> what I want. One of the roles of my code is to record video to disk as it is >> received from a camera. A magnetic hard disk can normall

Prioritize my own app's disk access

2016-07-05 Thread Jonathan Taylor
This is a long shot, but I thought I would ask in case an API exists to do what I want. One of the roles of my code is to record video to disk as it is received from a camera. A magnetic hard disk can normally keep up with this, but if the user is also doing other things on the computer (e.g. lo

Property synthesis trouble - 32 vs 64 bit builds

2016-07-05 Thread Jonathan Taylor
Hi all, I have a problem with property synthesis in my code, which I hope somebody can advise on. I find I have to write different property synthesis code for 32- or 64-bit builds in order to avoid compiler errors. A minimal demonstration of the problem can be found below - build as part of a

Tick marks on scroll bars

2016-06-13 Thread Jonathan Taylor
Hi all, Does anyone know a way of implementing "tick marks" on a scroll bar, in the way that Xcode does to mark code lines where there is an error/warning? From reading header files, I can't see any obvious built-in API to implement this feature, but perhaps somebody knows of a custom class tha

Re: ARC [was Protecting against "app nap"]

2016-05-12 Thread Jonathan Taylor
, Jens Alfke wrote: > >> On May 11, 2016, at 2:31 AM, Jonathan Taylor >> wrote: >> >> I guess I just found method naming a bit odd (not really referring to an >> object at all), and might have expected it to have an ‘alloc/new’ naming >> since I’d hav

Re: Protecting against "app nap"

2016-05-11 Thread Jonathan Taylor
Thankyou both for your replies - a couple of replies below: On 10 May 2016, at 23:33, Jens Alfke wrote: >> However, I was a bit surprised to find that I seem to need to explicitly >> retain the object I get back [this is non-ARC code…] if I want my request to >> remain in effect or even for the

Protecting against "app nap"

2016-05-10 Thread Jonathan Taylor
Hi all, I’m hoping somebody can help me work out how to protect my code against the effects of “app nap”. This code is driving a scientific experiment, unattended, and it is catastrophic when the OS decides that my timers running at 10Hz should only be fired every 10 seconds or so… which it tur

Re: Identify image file count in directory

2015-11-15 Thread Jonathan Taylor
Thanks Jens & Akis for your replies. Jens: > Most filesystems get noticeably slower when working with directories > containing large numbers of items. HFS+ does better than most, but I wouldn’t > be surprised if a lot of the slowness you’re seeing is just due to filesystem > overhead. If you ca

Re: Identify image file count in directory

2015-11-14 Thread Jonathan Taylor
now if there is a better way. Jonny. On 13 Nov 2015, at 16:54, Gary L. Wade wrote: > Try going down a level to the BSD layer APIs for directory contents traversal. > -- > Gary L. Wade (Sent from my iPad) > http://www.garywade.com/ > >> On Nov 13, 2015, at 8:28 AM, Jonat

Identify image file count in directory

2015-11-13 Thread Jonathan Taylor
Hi all, I want to be able to identify quickly (programatically) how many image files reside in a particular directory. At present I call: [NSFileManager defaultManager] contentsOfDirectoryAtPath:dir error:nil]; and then examine the type suffixes (which in comparison is very quick). When lookin

Re: Lost memory, GCD, dispatch sources, Cocoa bindings & User interface

2015-09-16 Thread Jonathan Taylor
Hi Jean, A wild guess that might or might not have any relevance to your problem: I see that you are wrapping your blocks with an autorelease pool, and that reminded me of a problem I dealt with a while back. As I understand it (and as discussed on this list some while back I think) pools may

KVO detection of changes to selection in NSOpenPanel

2015-07-20 Thread Jonathan Taylor
I’ve just noticed a glitch where my custom file preview box in an NSOpenPanel works fine on OS X 10.9.5 but does not get updated on 10.8.5. Specifically, I declare a dependency of my property on panel.filenames, panel.URL and panel.directoryURL (just to see if ANY of them fire), and none of them

Re: How to resize accessory view to match Open panel

2015-07-10 Thread Jonathan Taylor
. Hopefully that information might be of some use for posterity. Cheers Jonny On 9 Jul 2015, at 16:18, Ken Thomases wrote: > On Jul 9, 2015, at 7:05 AM, Jonathan Taylor > wrote: > >> I gave it a try, setting what I thought should be needed, but it doesn’t >> seem to be havi

Re: How to resize accessory view to match Open panel

2015-07-09 Thread Jonathan Taylor
On 9 Jul 2015, at 16:18, Ken Thomases wrote: > On Jul 9, 2015, at 7:05 AM, Jonathan Taylor > wrote: >> I gave it a try, setting what I thought should be needed, but it doesn’t >> seem to be having the desired effect as yet. I have the nib file set to “Use >> autola

Re: How to resize accessory view to match Open panel

2015-07-09 Thread Jonathan Taylor
> if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_8) { > [accessoryView setTranslatesAutoresizingMaskIntoConstraints:YES]; > } > > > > On Jul 8, 2015, at 8:33 AM, Jonathan Taylor > wrote: > >> I feel this should be a simple question, but I cannot find

How to resize accessory view to match Open panel

2015-07-08 Thread Jonathan Taylor
I feel this should be a simple question, but I cannot find an answer that works. I have an open panel to which I am trying to add an accessory view. That much works. However I would like the accessory view to resize to fit the width of the parent window. It’s just a textual description, after al

Re: Custom NSView subclass - expressing the fact that a property affects the displayed image

2015-05-27 Thread Jonathan Taylor
> The closest I got was creating a macro that uses np_thread_main() (or > whatever it was called exactly, it’s part of the pthreads API, IIRC) and > throws if it’s not the main thread. I call that e.g. in > observeValueForKeyPath overrides whenever I make thread-unsafe calls, so I > don’t accid

Re: Custom NSView subclass - expressing the fact that a property affects the displayed image

2015-05-23 Thread Jonathan Taylor
On 23 May 2015, at 00:21, Graham Cox wrote: > My advice is: forget it. What you’re doing is fine, and it’s the normal way > to make views repaint when a property changes. It’s not code ‘bloat’ either - > @synthesize produces code just as if you’d written it yourself. Any other way > than simply

Re: Custom NSView subclass - expressing the fact that a property affects the displayed image

2015-05-22 Thread Jonathan Taylor
Thanks for your reply Mike: > Well you could have a single key which you observe internally, and which all > the other keys feed into. Whenever it “changes”, treat that as time to mark > as needing display. That way you’re asking AppKit to do the work of creating > all the other observations fo

Custom NSView subclass - expressing the fact that a property affects the displayed image

2015-05-22 Thread Jonathan Taylor
I’m trying to think if there is an elegant way of handling the situation I find in some of my display code. I have a class which inherits from NSView and which overrides drawRect. The class has a number of properties, and if they change then the view needs redrawing. At present I have custom set

Re: NSNotificationQueue Question

2015-05-20 Thread Jonathan Taylor
> I have a bit of code that posts notifications to coalescing notification > queue. > [...] > In another place I need to force the notification queue to issue a did change > notification. > > This works but the problem is that there are undesirable side effects to > running the runloop once whe

Re: NSNotification coalescing - which one gets through?

2015-05-08 Thread Jonathan Taylor
Thanks for your replies Seth: >> I am trying to work out whether there are any rules that define which of >> multiple NSNotifications combined using coalescing actually get through to >> the receivers, and preferably a way of controlling that behaviour. This >> becomes relevant if for example t

Re: NSNotification coalescing - which one gets through?

2015-05-06 Thread Jonathan Taylor
11:54, Jonathan Taylor wrote: > I am trying to work out whether there are any rules that define which of > multiple NSNotifications combined using coalescing actually get through to > the receivers, and preferably a way of controlling that behaviour. This > becomes relevant if for e

NSNotification coalescing - which one gets through?

2015-05-06 Thread Jonathan Taylor
I am trying to work out whether there are any rules that define which of multiple NSNotifications combined using coalescing actually get through to the receivers, and preferably a way of controlling that behaviour. This becomes relevant if for example there is different UserInfo associated with

Re: User interface unresponsive in window

2015-04-17 Thread Jonathan Taylor
>> Am I right in thinking that when running under Xcode any drawing errors will >> be logged to the Xcode console? > > No, not unless they’re actually exceptions. Messages from other processes are > only going to appear in the system log. OK, thanks for your suggestion about checking the system

Re: User interface unresponsive in window

2015-04-15 Thread Jonathan Taylor
is). Any other ideas from anyone? Has anybody seen similar symptoms ever in the past (GUI not responding properly in one single window)? On 15 Apr 2015, at 18:01, Quincey Morris wrote: > On Apr 15, 2015, at 07:04 , Jonathan Taylor > wrote: >> >> From dimly-remembered past exp

User interface unresponsive in window

2015-04-15 Thread Jonathan Taylor
I've started encountering intermittent problems in one specific window in my application, where text input boxes become unresponsive, steppers remain highlighted after clicking, etc. I'm rather short of ideas on how to debug this, particular since I haven't worked out how to reproduce it reliabl

Text fields bound to numerical property - commas in number

2015-03-18 Thread Jonathan Taylor
I've come back to some old code that I haven't used for a while, and in the meantime I've done several OS upgrades and Xcode upgrades so plenty has changed, but my code is behaving in a strange way that I'm sure it didn't used to. I have a text field in my GUI bound to a property of type 'doubl

Re: NSPathControl (popup) - programatically show Choose dialog

2015-03-17 Thread Jonathan Taylor
>> Have you tried just displaying an NSOpenPanel yourself then setting the >> selected URL returned to the path control's URL property? >> >> Sent from my iPhone >> >>> On 2015/03/17, at 19:16, Jonathan Taylor >>> wrote: >>> >

Re: NSPathControl (popup) - programatically show Choose dialog

2015-03-17 Thread Jonathan Taylor
ng that there doesn't seem to be a way of doing what I had hoped... Cheers Jonny > >> On 2015/03/17, at 19:16, Jonathan Taylor >> wrote: >> >> OK, I've got part of the way to a solution, but haven't got it fully working >> yet. Perhaps the

Re: NSPathControl (popup) - programatically show Choose dialog

2015-03-17 Thread Jonathan Taylor
ng so it behaves correctly? Thanks again Jonny On 15 Mar 2015, at 13:18, Jonathan Taylor wrote: > I have a dialog which allows the user to select a folder containing data to > be processed, set various parameters that affect the processing, and displays > the result of the ana

NSPathControl (popup) - programatically show Choose dialog

2015-03-15 Thread Jonathan Taylor
I have a dialog which allows the user to select a folder containing data to be processed, set various parameters that affect the processing, and displays the result of the analysis. There is an NSPathControl (popup) to select the folder. Inevitably the first thing the user does is choose a folde

Re: Binding to selection of NSArrayController

2014-09-23 Thread Jonathan Taylor
tlet -> instance variable that I actually manipulate. Oh well, if that's the way it's meant to be... On 23 Sep 2014, at 19:57, Quincey Morris wrote: > On Sep 23, 2014, at 11:36 , Lee Ann Rucker wrote: > >> On Sep 23, 2014, at 9:15 AM, Jonathan Taylor >> wr

Re: Binding to selection of NSArrayController

2014-09-23 Thread Jonathan Taylor
ake > sure that selectionIndex (or something similar) from table is linked to > arraycontroller > > On Tue, Sep 23, 2014 at 6:15 PM, Jonathan Taylor > wrote: > Hi all, > > I feel this should be a very simple question, but I am struggling with it - > the tutorials and onli

Binding to selection of NSArrayController

2014-09-23 Thread Jonathan Taylor
Hi all, I feel this should be a very simple question, but I am struggling with it - the tutorials and online info I can find is either 5 years out of date or seem to imply that I am doing everything right! In my code I have an NSMutableArray of “message” objects, each with a number of properti

Re: NSPopupButton, bindings, and item state

2014-08-15 Thread Jonathan Taylor
>> After being impressed with bindings for an NSTableView, I’m looking at what >> I can do for a standalone NSPopupButton, in the hope of reducing the amount >> of glue code I have. The button isn’t just a simple one though, I need to: >> - Include separator items >> - Disable (grey out) some ite

NSPopupButton, bindings, and item state

2014-08-15 Thread Jonathan Taylor
After being impressed with bindings for an NSTableView, I’m looking at what I can do for a standalone NSPopupButton, in the hope of reducing the amount of glue code I have. The button isn’t just a simple one though, I need to: - Include separator items - Disable (grey out) some items - Select mul

Re: NSMenu in NSTableView column

2014-08-13 Thread Jonathan Taylor
>> Ah, I've worked out the underlying problem I've been having. I had been >> trying things along these lines and completely failing to get the popup menu >> to populate correctly. It was working for a standalone popup but not within >> the table, and I was assuming I was doing something wrong a

Re: NSMenu in NSTableView column

2014-08-13 Thread Jonathan Taylor
> I would create a class, say, SignalChannel, with "name" (for description, but > we may not ant to use "description" for obvious reasons...) and "channelID" > properties. I would then populate the NSPopupButtonCell with SignalChannel > objects. This will abstract the model from the view, which

Re: NSMenu in NSTableView column

2014-08-12 Thread Jonathan Taylor
>>> My question then is how should I access the tags in the popup menu in order >>> to work out which tag corresponds to the selected item in each row? >> >> If I understand your setup correctly, the most direct route is to set an >> action on each menu item. > > Ah ok, I've revisited that and

Re: NSMenu in NSTableView column

2014-08-12 Thread Jonathan Taylor
>> My question then is how should I access the tags in the popup menu in order >> to work out which tag corresponds to the selected item in each row? > > If I understand your setup correctly, the most direct route is to set an > action on each menu item. Ah ok, I've revisited that and got it t

NSMenu in NSTableView column

2014-08-12 Thread Jonathan Taylor
Hi all, I am trying to implement a popup menu in an NSTableView column. I seem to have the bindings all set up so that the values in my NSArray are updated according to the options the user selects in the table. However, I would like to have some way of accessing the tag on the menu item that w

Contribute some dictionary keys with registerDefaults

2014-06-18 Thread Jonathan Taylor
I currently have a plist which contains some configuration values; at start of day I use the following call to make certain "factory settings" available to the application through NSUserDefaults: [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithContents

Re: Color closest to color

2014-06-17 Thread Jonathan Taylor
distances between the given colour and each of the standard colours, > and the one with the minimal squared distance is the best match. > > Better methods may exist, consult a book on computer vision or fine arts > maybe? > > On Jun 17, 2014, at 18:52, Jonathan Taylor > wro

Color closest to color

2014-06-17 Thread Jonathan Taylor
Hi all, Is there a way of identifying the closest match to a given NSColor, out of a list of possible colors to match? The user could have selected any color using the color picker, but I would like to know whether it is "approximately red", green, blue or white. Of course, it might be e.g. ma

Re: GCD killed my performance

2014-04-25 Thread Jonathan Taylor
Have you looked at the output from System Trace on both systems? I often find that to be informative. That might or might not be the way to tell, but have you considered that the very different CPU characteristics might mean that the actual timing and pattern of database commands is different o

Re: Bindings for dynamically populated menu

2014-04-07 Thread Jonathan Taylor
On 7 Apr 2014, at 11:25, Keith J. Schultz wrote: > Hi Jonny, > > try Menu items on the fly! > > To my knowledge you can not use IB! Thanks for your reply keith. I hadn't tried those search terms, but no that didn't get me anything relevant either. All I could find was one old thread in which

Bindings for dynamically populated menu

2014-04-07 Thread Jonathan Taylor
This must be a very basic question, but I am evidently having difficulty finding the right search terms. Can anyone point me to some sample code that will show how to implement a menu whose items are populated at runtime? I would have expected to be able to bind a menu object to an NSArray consi

Re: Window controllers and memory leaks

2013-09-16 Thread Jonathan Taylor
Thanks Kyle and Jerry. It feels a bit strange to be adding extra glue code to track otherwise-completely-autonomous windows (and controllers), but that has certainly done the trick. I found the static analyzer a bit odd to get used to - it sometimes gives purportedly very detailed explanations

Window controllers and memory leaks

2013-09-13 Thread Jonathan Taylor
This must be an incredibly basic question, but I haven't found an answer I'm convinced by (apologies if I have missed something on the list). My question relates to window controllers, and how ownership, retain/release etc should be managed in order to (a) be correct and (b) satisfy the static a

Re: Debugging kCGErrorIllegalArgument: CGSUnionRegionWithRect : Invalid region

2013-09-05 Thread Jonathan Taylor
> Do you have any secondary threads? I assume you do. Indeed! > Any code that touches a view, no matter how indirectly, could be the culprit. > Bear in mind that sending any message to any view (controls, etc) might > invoke -setNeedsDisplay: which in turn could be the trigger for the problem.

Re: Threadsafe copy of objective c object

2013-09-05 Thread Jonathan Taylor
On 4 Sep 2013, at 16:46, Marcel Weiher wrote: >>> Unless there is some dire reason not to do this, I would make a copy on the >>> main thread every time the UI changes, and stash that copy somewhere the >>> worker thread can access it easily. >> >> That's a really good plan, I realised that last

Re: Debugging kCGErrorIllegalArgument: CGSUnionRegionWithRect : Invalid region

2013-09-05 Thread Jonathan Taylor
> You can't do any UI-related updates from a secondary thread, you must ask the > main thread to do it. > > It might not be progress bars but anything at all that's being drawn from a > secondary thread. The error itself could indicate that an internal data > structure was used or updated by an

Debugging kCGErrorIllegalArgument: CGSUnionRegionWithRect : Invalid region

2013-09-05 Thread Jonathan Taylor
Can anybody help me diagnose an error that I see intermittently? The errors are as follows: Thu Sep 5 10:11:11 Jonathan-Taylors-Mac-Pro.local Spim GUI[34152] : kCGErrorIllegalArgument: CGSUnionRegionWithRect : Invalid region Thu Sep 5 10:11:11 Jonathan-Taylors-Mac-Pro.local Spim GUI[34152] :

Re: Threadsafe copy of objective c object

2013-09-04 Thread Jonathan Taylor
Thanks to everyone who has chimed in on this one - you've all been really helpful. Looks like some conclusions are emerging; some selected replies below. On 3 Sep 2013, at 20:21, Tom Davie wrote: > Remove the mutation methods. Make your object immutable, the referential > transparency will giv

Re: Threadsafe copy of objective c object

2013-09-03 Thread Jonathan Taylor
Ah. In my original email I didn't explain *why* it is that "ideally I would like to make the copy on a thread other than the main thread". The algorithm is doing real-time video processing, and I very much want to avoid holding up anything in that code path by synchronizing with the main queue.

Re: Threadsafe copy of objective c object

2013-09-03 Thread Jonathan Taylor
people are saying as if that's what I may have to do... On 3 Sep 2013, at 13:54, Robert Vojta wrote: > On Tue, Sep 3, 2013 at 2:39 PM, Jonathan Taylor > wrote: > > The primary instance of the object (call it MyParameters) is bound to UI > elements. Changes to the UI

Re: Threadsafe copy of objective c object

2013-09-03 Thread Jonathan Taylor
> Is it possible to reverse the issue? Keep the original object (living on the > main thread) untouched, make a copy for algorithm processing as an async > task, then, when done, update the original object from the copy that may have > been changed during async processing? Or will that cause the

Re: Threadsafe copy of objective c object

2013-09-03 Thread Jonathan Taylor
snapshot of the state of the entire object, i.e. copy not taken while object is being updated. Actually, I suspect this last condition is not a problem for my specific case, but best to be on the safe side, for several different reasons. On 3 Sep 2013, at 12:04, Graham Cox wrote: > > O

Threadsafe copy of objective c object

2013-09-03 Thread Jonathan Taylor
This feels like it should be a very basic question, but it's not one I've managed to find an answer to - can somebody here advise? I have an objective c object which contains a number of properties that serve as parameters for an algorithm. They are bound to UI elements. I would like to take a

Re: Memory not being released in a timely manner

2013-06-10 Thread Jonathan Taylor
Thanks for your comments Ken. It was really good to learn about how to use heapshots effectively, that's definitely something I'm going to use again in future. In this case it did provide ~some~ more information on what is going on. Just to be clear, the problem is now solved by wrapping the cor

Re: Memory not being released in a timely manner

2013-06-07 Thread Jonathan Taylor
> It smells like you're doing a lot of processing with temporary objects, in a > loop, without bracketing the loop body in @autoreleasepool{}, but I remember > you saying you're not. Oh dear. Oh dear. You are right. I know this is what everybody has been telling me all along. I have a tiny on

Re: Memory not being released in a timely manner

2013-06-07 Thread Jonathan Taylor
> The Allocations instrument should report objects with pending autoreleases as > ordinary live objects. (Note that many objects with retain count == pending > autorelease count will be retained again before the autorelease pool pops.) > > In OS X 10.8 and iOS 6 simulator, you can set environmen

Re: Memory not being released in a timely manner

2013-06-06 Thread Jonathan Taylor
Thankyou all for your replies. A few responses - On 4 Jun 2013, at 16:30, Jeff Johnson wrote: > We've run into this issue in a number of apps. As a workaround, we add a > timer to the main thread and have it fire periodically. The timer's action > method does the following: Thanks again! I've i

Re: Memory not being released in a timely manner

2013-06-04 Thread Jonathan Taylor
ata1:0 > data2:0] > [NSApp postEvent:event atStart:YES]; > > This basically "tickles" the event loop and causes the autorelease pool to > drain. > > -Jeff > > > On Jun 3, 2013, at 10:59 AM, Jonathan Taylor > wrote: > >> Hi all, >> >&g

Memory not being released in a timely manner

2013-06-04 Thread Jonathan Taylor
Hi all, Can anybody advise what tools I should be using to debug a particular out of memory condition - and maybe even how I can fix it? The error that I ultimately encounter (in a 32-bit application on Snow Leopard) is: 2013-06-03 15:44:30.271 MyApplication[25115:a0f] NSImage: Insufficient memo

Re: NSAutounbinder not releasing my object in a timely manner

2012-07-20 Thread Jonathan Taylor
Thankyou both for your very helpful replies. The dispatch group approach sounds like a nice one - especially using dispatch_group_notify, which I had somehow overlooked. Thanks also Ken for your detailed reply to my ramblings, that was very useful for getting my understanding straightened out. J

Re: GCD question

2012-07-19 Thread Jonathan Taylor
> If I use this to initiate a background "thread": > > > dispatch_async(dispatch_get_global_queue(0, 0), ^{ > > // do some stuff > > [self runMyFunction]; > > [self runAnotherFunction]; > > // do some more stuff > > }); > > > My question is with my sample calling runMyFunction or runAnothe

Re: NSAutounbinder not releasing my object in a timely manner

2012-07-19 Thread Jonathan Taylor
this nasty NSAutounbinder thingy then jumps in and re-retains it in some evil under-the-covers voodoo to do with avoiding retain cycles (as I understand it). Unfortunately the balancing autorelease only occurs 16 seconds later when I move the mouse! While not catastrophic thi

NSAutounbinder not releasing my object in a timely manner

2012-07-18 Thread Jonathan Taylor
I am tearing my hair out here with yet another retain issue with the NSAutounbinder. I don't know what I am doing to keep hitting these problems, and unfortunately going back through peoples past (very helpful) replies to my questions on both this and blocks+autorelease pools has not shed any li

Re: "Capturing 'self' strongly in this block is likely to lead to a retain cycle"

2012-07-10 Thread Jonathan Taylor
>> In practice, NSOperationQueue probably releases the block when it's done >> with it > > I'm curious about your use of the word "probably" here. Can you explain? This is probably not what the OP had in mind, but I might mention that I've seen situations where autoreleases associated with NSOp

Re: "Capturing 'self' strongly in this block is likely to lead to a retain cycle"

2012-07-10 Thread Jonathan Taylor
>> In practice, NSOperationQueue probably releases the block when it's done >> with it > > I'm curious about your use of the word "probably" here. Can you explain? This is probably not what the OP had in mind, but I might mention that I've seen situations where autoreleases associated with NSOp

Re: NSWindowController subclasses, and retain cycles

2012-05-24 Thread Jonathan Taylor
On 24 May 2012, at 16:27, Kyle Sluder wrote: >> 1. If I do not set B's pointer to A, both A and B are deallocated correctly >> 2. If instead I set B's pointer to A, but reset it to nil just before B is >> closed, both A and B are deallocated correctly >> 3. If instead B still has a live pointer to

NSWindowController subclasses, and retain cycles

2012-05-24 Thread Jonathan Taylor
I have been battling a retain cycle for a couple of hours, assuming I am at fault, but I am starting to think there is something fishy going on. Can anybody advise? - I have a window controller subclass (and associated window) A, and a separate window controller subclass (and associated window)

Re: Binding and multithreading

2012-03-24 Thread Jonathan Taylor
eForKeyPath:ofObject:change:context to update > the GUI in this context. I don't know of any better method than what the OP > suggested. > > Cheers, > Dave > > On 2012-03-23, at 6:32 PM, Jan E. Schotsman wrote: > >> Jonathan Taylor wrote: >>> I hav

Binding and multithreading

2012-03-23 Thread Jonathan Taylor
I have been struggling with a problem which I think I have eventually realised is down to me not handling multithreading issues properly. The situation is I have some computationally-demanding code that is running in a separate thread. This has input parameters and state variables associated wit

Re: ObjectController preventing WindowController from releasing

2011-11-08 Thread Jonathan Taylor
> Well, in this case I certainly think it would be better to bind the object > controller to File's Owner.camera. Really, I wasn't so much getting at > anything in particular, I just find it odd for an object controller to have a > window controller as its content. I also find it odd to bind t

Re: ObjectController preventing WindowController from releasing

2011-11-07 Thread Jonathan Taylor
Hi Ken, Thanks very much for your reply! >> I have a window and window controller which in the absence of an object >> controller work fine, and both are deallocated when the window is closed. If >> I add an ObjectController to the NIB and bind its "Content Object" to >> "File's Owner.self" th

ObjectController preventing WindowController from releasing

2011-11-07 Thread Jonathan Taylor
Sorry. Re-sending under what I think is a more correct title. I only realised after I hit send! Begin forwarded message: > From: Jonathan Taylor > Date: 7 November 2011 16:08:13 GMT > To: cocoa-dev > Subject: ObjectController preventing window from closing > > Hi all, >

ObjectController preventing window from closing

2011-11-07 Thread Jonathan Taylor
Hi all, This is probably a very basic question, but I am out of ideas and hoping someone can offer some help. I should say that I'm afraid I'm somewhat out of my depth with ObjectControllers: I added some seemingly simple bindings at the recommendation of a poster on here, and I thought I under

Re: Keeping grayscale image grayscale

2011-10-18 Thread Jonathan Taylor
Belated thanks for the various replies to my question. I'm working through the posted code and links now and looking at what I can learn from it. One query though: On 12 Oct 2011, at 16:42, Heinrich Giesen wrote: > Another rule of thumb is: if you need -[NSImage TIFFRepresentation] you do > som

Keeping grayscale image grayscale

2011-10-10 Thread Jonathan Taylor
I'm working with 16-bit grayscale images, and for the most part I'm just manipulating bits within NSBitmapImageRep objects. However for convenience it would be nice to do some stuff with NSImages, particularly when rescaling and suchlike. The problem is that whenever I draw into such an NSImage

  1   2   >