Re: dealloc and scarce resources

2011-06-30 Thread Jean-Daniel Dupas
Le 30 juin 2011 à 08:19, James Merkel a écrit : > > On Jun 29, 2011, at 11:07 PM, Kyle Sluder wrote: > >> On Wed, Jun 29, 2011 at 10:38 PM, James Merkel wrote: >>> Ok, thanks. For what I'm doing file descriptors are not a scarce resource. >> >> File descriptors are almost always a scarce reso

Re: dealloc and scarce resources

2011-06-30 Thread Ken Thomases
On Jun 30, 2011, at 3:02 AM, Jean-Daniel Dupas wrote: > Le 30 juin 2011 à 08:19, James Merkel a écrit : > >> Ok, I'm looking at my application in Instruments File Activity. The column >> labeled FD I assume means file descriptors. Is that the total number of FDs >> in use at any given time? >

Scaling CALayer produces blurry/distorted text

2011-06-30 Thread Ajay Sabhaney
Hello, I have an application in which the user can continuously zoom and pan a canvas (kind of like Google Maps). On the canvas, a user can have multiple text items. Each text item is a Core Animation layer, and the text is drawn using NSLayoutManager's drawGlyphsForGlyphRange method. When t

Re: NSUndoManager - unstable state

2011-06-30 Thread Jerry Krinock
On 2011 Jun 29, at 23:08, Kyle Sluder wrote: > On Wed, Jun 29, 2011 at 10:40 PM, wrote: >> Is there a way to check if the NSUndomanager is in an unstable state and >> reset it? > > No, NSUndoManager is very fragile, and if it gets into a bad state it > is not recoverable. and it's a black bo

Re: dealloc and scarce resources

2011-06-30 Thread James Merkel
On Jun 30, 2011, at 2:01 AM, Ken Thomases wrote: On Jun 30, 2011, at 3:02 AM, Jean-Daniel Dupas wrote: Le 30 juin 2011 à 08:19, James Merkel a écrit : Ok, I'm looking at my application in Instruments File Activity. The column labeled FD I assume means file descriptors. Is that the total

Re: Properties, Attributes and Retain+Autorelease

2011-06-30 Thread Markus Hanauska
On 2011-06-29, at 21:50 , Quincey Morris wrote: > You're looking for provable correctness. That's laudable, and will probably > mean that you keep all of your fingers. But you'll still end up in the > emergency room -- in your case it will be for a stress-induced ulcer. :) My university profes

Re: Properties, Attributes and Retain+Autorelease (SOLVED)

2011-06-30 Thread Markus Hanauska
Since nobody was able to provide real answers to my questions, I wrote some dummy code to find out as much about that issue as possible. Here are the results: Remember, I listed the following cases: > a) retain > b) retain, nonatomic > c) copy > d) copy, nonatomic

Re: dealloc and scarce resources

2011-06-30 Thread James Merkel
On Jun 30, 2011, at 9:20 AM, James Merkel wrote: On Jun 30, 2011, at 2:01 AM, Ken Thomases wrote: On Jun 30, 2011, at 3:02 AM, Jean-Daniel Dupas wrote: Le 30 juin 2011 à 08:19, James Merkel a écrit : Ok, I'm looking at my application in Instruments File Activity. The column labeled FD I

[Q] Will the be any problem in implementing an NSArray method using fast enumeration?

2011-06-30 Thread JongAm Park
Hello, I wrote a method for NSArray. - (NSArray *)objectsForKey:(id)key { NSMutableArray *objectsArray = [NSMutableArray arrayWithCapacity:10]; for( id item in self ) { [objectsArray addObject:[item objectForKey:key]]; } r

Re: [Q] Will the be any problem in implementing an NSArray method using fast enumeration?

2011-06-30 Thread Dave DeLong
Yeah, that should be fine, but it's unnecessary. You can just do: NSArray *objectsArray = [theArray valueForKey:key]; And it'll do pretty much the same thing (except that it'll call -valueForKey: on each item in the array, and not objectForKey:. However, if the objects are NSDictionaries, tha

Re: dealloc and scarce resources

2011-06-30 Thread Kyle Sluder
On Thu, Jun 30, 2011 at 9:20 AM, James Merkel wrote: > After a fair amount of application warm-up the FD > shows 25 to 26. So, I assume I'm ok. And what happens when (not if) you introduce a leak, and these objects live longer than you expect them to? Or worse, someone else starts holding on to t

Re: dealloc and scarce resources

2011-06-30 Thread James Merkel
On Jun 30, 2011, at 12:04 PM, Kyle Sluder wrote: On Thu, Jun 30, 2011 at 9:20 AM, James Merkel wrote: After a fair amount of application warm-up the FD shows 25 to 26. So, I assume I'm ok. And what happens when (not if) you introduce a leak, and these objects live longer than you expect th

Re: dealloc and scarce resources

2011-06-30 Thread Kyle Sluder
On Thu, Jun 30, 2011 at 12:12 PM, James Merkel wrote: > Ok, I don't know what an -invalidate method is, but I'll look it up. It's the thing Wim talked about. An explicit way to release the scarce resource you're holding on to. Depending on what that resource is, an appropriate name might be -clos

Re: [Q] Will the be any problem in implementing an NSArray method using fast enumeration?

2011-06-30 Thread Heath Borders
You might also try HBCollections, a series of collections categories I wrote that makes it easy to do stuff like this. https://github.com/hborders/HBCollections -Heath On Jun 30, 2011 2:10 PM, "Dave DeLong" wrote: ___ Cocoa-dev mailing list (Cocoa-dev

Re: dealloc and scarce resources

2011-06-30 Thread James Merkel
On Jun 30, 2011, at 12:21 PM, Kyle Sluder wrote: On Thu, Jun 30, 2011 at 12:12 PM, James Merkel wrote: Ok, I don't know what an -invalidate method is, but I'll look it up. It's the thing Wim talked about. An explicit way to release the scarce resource you're holding on to. Depending on wha

Re: Activate app but bring only *one* window to the front

2011-06-30 Thread Jerry Krinock
On 2011 Jun 29, at 10:11, Kyle Sluder wrote: > -[NSRunningApplication activateWithOptions:] Thank you, Kyle, that works. Indeed, in Mac OS 10.6+, the code [[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps] ; activates the app, but only brin

Re: [Q] Will the be any problem in implementing an NSArray method using fast enumeration?

2011-06-30 Thread JongAm Park
Um... Thanks for your reply. The last time I used that was about 5 or 6 years ago, and I wondered yesterday where it went away. :) Thanks for pointing out that method. BTW, my actual question was if it is meant to use fast enumeration in a collection class implementation. Although I tried to ad

Re: dealloc and scarce resources

2011-06-30 Thread Jerry Krinock
On 2011 Jun 30, at 13:33, James Merkel wrote: > I'm not sure where I would do that [-invalidate, releaseResources, > removeObservers, whatever] That's a common dilemma. There is no general solution. Each situation will have its own least-worst solution. > Apple could have helped things alon

Re: dealloc and scarce resources

2011-06-30 Thread Jens Alfke
On Jun 30, 2011, at 1:33 PM, James Merkel wrote: > We find from Kernighan and Ritchie (K&R) second edition, section 8.1 that a > file descriptor is a small non-negative integer that refers to a file and is > maintained by the system. Actually file descriptors are used for any sort of I/O chann

Re: Activate app but bring only *one* window to the front

2011-06-30 Thread Scott Ribe
On Jun 30, 2011, at 2:39 PM, Jerry Krinock wrote: > However, Cocoa still wins. My purpose was to show an alert-type of window > (my own custom version of NSAlert) without bringing forward a document > window. Initially, it works, but when the user clicks a button which sends > -[NSWindow clos

Re: [Q] Will the be any problem in implementing an NSArray method using fast enumeration?

2011-06-30 Thread Quincey Morris
On Jun 30, 2011, at 13:51, JongAm Park wrote: > The rationale behind "enumerator" pattern is to unify the way to access > collection classes no matter what they actually look like. > So, enumerator pattern is actually written in index based iteration wrapped > with enumerator pattern. > Similar

Re: [Q] Will the be any problem in implementing an NSArray method using fast enumeration?

2011-06-30 Thread JongAm Park
Wow.. great information! Thank you very much for sharing your idea! It definitely helped me! JongAm Park On Jun 30, 2011, at 2:41 PM, Quincey Morris wrote: > > On Jun 30, 2011, at 13:51, JongAm Park wrote: > >> The rationale behind "enumerator" pattern is to unify the way to access >> collec

Core Data: stop object from firing fault?

2011-06-30 Thread Michael Link
Is there anyway to stop an NSManagedObject from firing a fault, say because it's actually been deleted? For instance if an object is created on the main thread and is then punted to a background thread and deleted (in a separate context of course) then the changes are merged back to the main th

Instance Variables of NSManagedObject Subclasses

2011-06-30 Thread Allen Ingling
Dear cocoa-dev list, I want my NSManagedObjects to retain a variable valid for the lifetime the application instance but not between instances of the application. So I have subclassed NSManagedObject and added an instance variable to the NSManagedObject subclass and defined a property as follows:

Instance Variables of NSManagedObject Subclasses

2011-06-30 Thread Allen Ingling
Dear cocoa-dev list, I want my NSManagedObjects to retain a variable valid for the lifetime the application instance but not between instances of the application. So I have subclassed NSManagedObject and added an instance variable to the NSManagedObject subclass and defined a property as follows:

Instance Variables of NSManagedObject Subclasses

2011-06-30 Thread Allen Ingling
Dear cocoa-dev list, I want my NSManagedObjects to retain a variable valid for the lifetime the application instance but not between instances of the application. So I have subclassed NSManagedObject and added an instance variable to the NSManagedObject subclass and defined a property as follows:

Re: dealloc and scarce resources

2011-06-30 Thread Greg Guerin
James Merkel wrote: Everyone doesn't approach this stuff with the same background. We find from Kernighan and Ritchie (K&R) second edition, section 8.1 that a file descriptor is a small non-negative integer that refers to a file and is maintained by the system. Wikipedia is also a useful r

Re: dealloc and scarce resources

2011-06-30 Thread Jeffrey Walton
On Thu, Jun 30, 2011 at 7:06 PM, Greg Guerin wrote: > James Merkel wrote: > >> Everyone doesn't approach this stuff with the same background. >> We find from Kernighan and Ritchie (K&R) second edition, section 8.1 that >> a file descriptor is a small non-negative integer that refers to a file and

Re: Core Data: stop object from firing fault?

2011-06-30 Thread Mike Abdullah
On 30 Jun 2011, at 23:01, Michael Link wrote: > Is there anyway to stop an NSManagedObject from firing a fault, say because > it's actually been deleted? > > For instance if an object is created on the main thread and is then punted to > a background thread and deleted (in a separate context o

Re: dealloc and scarce resources

2011-06-30 Thread Greg Guerin
Jeffrey Walton wrote: Wikipedia is hardly the definitive reference. SEO comes to mind. Luckily, I didn't say Wikipedia was a definitive reference. I said "useful reference". And anyone at all familiar with it knows full well that its accuracy (and usefulness) can vary widely. I, for one

Modify metadata of existing file using AVFoundation

2011-06-30 Thread Indragie Karunaratne
Hi all, I'm playing around a bit with AVFoundation and it seems to have all the audio related functionality I could possibly want (playback, metadata, mixing, etc.) but there's one thing I'm having trouble figuring out. I know how to read metadata from a file via AVAsset's -commonMetadata meth

Re: Activate app but bring only *one* window to the front

2011-06-30 Thread Ken Thomases
On Jun 30, 2011, at 3:39 PM, Jerry Krinock wrote: > On 2011 Jun 29, at 10:11, Kyle Sluder wrote: > >> -[NSRunningApplication activateWithOptions:] > > Thank you, Kyle, that works. Indeed, in Mac OS 10.6+, the code > > [[NSRunningApplication currentApplication] > activateWithOptions:NSApplicat

Re: dealloc and scarce resources

2011-06-30 Thread Ken Thomases
On Jun 30, 2011, at 3:33 PM, James Merkel wrote: > So, my guess is that when Instruments shows an FD of -1 it refers to an FD > that isn't mine. What the File Activity instrument is showing in its event list is a certain subset of system calls which operate on file descriptors. It is showing

Re: dealloc and scarce resources

2011-06-30 Thread James Merkel
Not to beat this subject to death, but I just realized that what Kyle Sluder and Wlm Lewis were saying is very easy to implement. All I need is a method that just closes the file -- one line of code. Then wherever I was sending the -release, I need to also send a separate -close. it could be

Re: dealloc and scarce resources

2011-06-30 Thread Kyle Sluder
On Thu, Jun 30, 2011 at 6:34 PM, James Merkel wrote: > Then wherever I was sending the -release, I need to also send a separate >  -close. it could be before or after the release, it doesn't really matter. No, it really needs to be before the -release. When you call -release, you relinquish your

Re: dealloc and scarce resources

2011-06-30 Thread James Merkel
On Jun 30, 2011, at 6:39 PM, Kyle Sluder wrote: On Thu, Jun 30, 2011 at 6:34 PM, James Merkel wrote: Then wherever I was sending the -release, I need to also send a separate -close. it could be before or after the release, it doesn't really matter. No, it really needs to be before the

tableview, button with view and bindings

2011-06-30 Thread R
Can anyone give me some guidance on adding a button w/ image to a tableview using bindings. I've had good luck adding buttons to a tableview by dropping in a button cell. But adding the image is giving me some problems. The image will be retrieved from the object represented on the row of the ta

How to get the applicaiton name that loads bundle

2011-06-30 Thread Chen, Jeff (SDCC)
Dear All, Now I'm developing the printer driver, and I want to realize the following specificaiton: 1, If the current applicaiton loading my PDE is "TextEdit" or "Preview", do actionA 2, If the current application loading my PDE is another application, do actionB. But I don't know how to get th

Re: tableview, button with view and bindings

2011-06-30 Thread R
Clarification: a button with an image in a tableview. On Jul 1, 12:13 am, R wrote: > Can anyone give me some guidance on adding a button w/ image to a > tableview using bindings.  I've had good luck adding buttons to a > tableview by dropping in a button cell.  But adding the image is > giv

Re: tableview, button with view and bindings

2011-06-30 Thread Quincey Morris
On Jun 30, 2011, at 23:13, R wrote: > Can anyone give me some guidance on adding a button w/ image to a > tableview using bindings. I've had good luck adding buttons to a > tableview by dropping in a button cell. But adding the image is > giving me some problems. The image will be retrieved fro

Re: How to get the applicaiton name that loads bundle

2011-06-30 Thread Scott Ribe
On Jul 1, 2011, at 12:25 AM, Chen, Jeff (SDCC) wrote: > Is there anyone who knows this? Haven't done it from a PDE specifically, but in general [NSBundle mainBundle] will give you the bundle of the executing application, and you can go from there. -- Scott Ribe scott_r...@elevated-dev.com htt