Re: Using runtime functions to match up object types safely when setting properties

2008-12-20 Thread Andrew Farmer
On 19 Dec 08, at 19:28, Ken Thomases wrote: I think your only avenue is to implement explicit KVV methods for your properties which have the necessary knowledge to test their type. I suppose you could file a feature request to extend declared properties so they can synthesize a type-checkin

Re: Using runtime functions to match up object types safely when setting properties

2008-12-20 Thread Graham Cox
On 20 Dec 2008, at 8:05 pm, Andrew Farmer wrote: However, I think you've overengineering things here. The standard runtime introspection methods, like [NSObject class] and [NSObject isKindOfClass:], should be more than enough to implement this sort of functionality. You might be right a

Re: Newbie Question: implementing a stack

2008-12-20 Thread Dave DeLong
Sorry to jump in to this a little late, but a guy in our CocoaHeads group wrote a framework as part of his Master's thesis work. It's a datastructure framework and contains a bunch of datastructures not available (publicly) in Cocoa, such as stacks, queues, dequeues, avl/ rb/aa-trees, treap

Re: Question Regarding the Memory Address of Objects

2008-12-20 Thread Dong Feng
I have a concern that the direct use of a pointer as a memory address may have a problem in the case of GC. In Java, object reference is not a simple memory address because objects may be moved by GC. Does Cocoa has a GC implementation avoid it? 2008/12/19 Carter R. Harrison : > > On Dec 18, 200

Re: Question Regarding the Memory Address of Objects

2008-12-20 Thread Clark S. Cox III
The objective-c garbage collector does not move objects, so that is not an issue with using raw pointers. Sent from my iPhone On Dec 20, 2008, at 6:50, "Dong Feng" wrote: I have a concern that the direct use of a pointer as a memory address may have a problem in the case of GC. In Java, obj

Sorting an NSMutableArray

2008-12-20 Thread Jacob Rhoden
How do you sort an NSMutableArray, when the difference between the two objects is determined by information not contained completely within the objects themselves. ie in Java you can implement a Comparator that takes two objects to compare then. Is this similar in Cocoa? ie in this case I need

Re: Sorting an NSMutableArray

2008-12-20 Thread Ricky Sharp
On Dec 20, 2008, at 6:15 AM, Jacob Rhoden wrote: How do you sort an NSMutableArray, when the difference between the two objects is determined by information not contained completely within the objects themselves. ie in Java you can implement a Comparator that takes two objects to compare t

Re: Listening for changes

2008-12-20 Thread Andre Masse
Thanks for the idea Mike. Not sure how I could implement this without sending the notification in every setter of the class though... Andre Masse On Dec 19, 2008, at 19:24, Mike Abdullah wrote: Since you apparently want to just know that one of the fields changed, but not which one specif

Re: Optimizing NSRectFill

2008-12-20 Thread Oleg Krupnov
Here is how I arrived at the conclusion that NSRectFill is the bottleneck. (I cannot show the code because it's spread over objects). The slowness of redraw is only noticeable when I drag the mouse, e.g. to resize an object in the custom view. I see that update of the resized object is always late

Re: Optimizing NSRectFill

2008-12-20 Thread Jean-Daniel Dupas
Le 20 déc. 08 à 15:22, Oleg Krupnov a écrit : Here is how I arrived at the conclusion that NSRectFill is the bottleneck. (I cannot show the code because it's spread over objects). The slowness of redraw is only noticeable when I drag the mouse, e.g. to resize an object in the custom view. I se

Re: Optimizing NSRectFill

2008-12-20 Thread Jean-Daniel Dupas
Sorry for the blank previous mail. Try to call NSFillRect with the rect pased as parameter in drawRect: and before applying the scaling method. As the rect parameter contains the invalid rect in screen coordinates, you don't have to transform it before filling the rect with white. Le 20 dé

Re: Get notified of fullscreen switch

2008-12-20 Thread Joachim Deelen
Hi Eric, thanks for the quick response. "Listening" to the Carbon Event you described did it. The only "disadvantage" is: Now the App depends on Carbon.framework so far it was Cocoa, Quartz, QuartzCore and ScriptingBridge only But, between the lines of your reply I could read that the

Re: Optimizing NSRectFill

2008-12-20 Thread Jean-Daniel Dupas
Le 20 déc. 08 à 15:33, Jean-Daniel Dupas a écrit : Sorry for the blank previous mail. Try to call NSFillRect with the rect pased as parameter in drawRect: and before applying the scaling method. As the rect parameter contains the invalid rect in screen coordinates, you don't have to transf

Trackpad multi touch events in Mac OSX

2008-12-20 Thread Andreas Eriksson
Hi, is there a public API to catch the new trackpad multi touch events in Mac OSX? Regards, Andreas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at c

MathPaper (Chapter 10) fails

2008-12-20 Thread Richard S. French
MathPaper project ­ chapter 10 in Oreilly¹s ³Building Cocoa Applications² fails with the following error: ³2008-12-20 11:23:59.664 MathPaper[517] *** -[NSCFDictionary setObject:forKey:]: attempt to insert nil value² Note that I am using Xcode 2.4.1. I also have the evaluator copied under MathPaper

How to use animation for CALayer frame.size attribute?

2008-12-20 Thread Alex . Wang
Hi everyone.I am trying to create some animation when to change the size of a CALayer object. My code looks like this: CABasicAnimation * _animation =[CABasicAnimation animation]. [_animation setKeyPath:@"frame.size"]; NSSize _size; *_size.**width** = 400**;* *_size.**height** = 300**;* *_animat

Re: Using runtime functions to match up object types safely when setting properties

2008-12-20 Thread Michael Ash
On Sat, Dec 20, 2008 at 5:16 AM, Graham Cox wrote: > KVV works pretty well for this - it also solves another related situation > where I can usefully convert objects to other types in some cases - but what > I still haven't quite worked out yet is how to *prevent* the situation > arising in the fi

Re: Question Regarding the Memory Address of Objects

2008-12-20 Thread Michael Ash
On Sat, Dec 20, 2008 at 7:00 AM, Clark S. Cox III wrote: > The objective-c garbage collector does not move objects, so that is not an > issue with using raw pointers. But note that storing a pointer value in a string like this is still problematic under garbage collection. It will not act like a

Re: Optimizing NSRectFill

2008-12-20 Thread Michael Ash
On Sat, Dec 20, 2008 at 9:22 AM, Oleg Krupnov wrote: > Here is how I arrived at the conclusion that NSRectFill is the > bottleneck. (I cannot show the code because it's spread over objects). > > The slowness of redraw is only noticeable when I drag the mouse, e.g. > to resize an object in the cust

toolbar to view gradient displaying correctly only sometimes?

2008-12-20 Thread Chunk 1978
i have a window with a toolbar, and instead of having a sharp separation between the toolbar and window, i've created a gradient from toolbar color to window color (which is simply a custom view placed over the window). this gradient looks correct on my iMac 24", and correct on other MacBooks. ho

Re: Optimizing NSRectFill

2008-12-20 Thread Bill Bumgarner
On Dec 20, 2008, at 9:18 AM, Michael Ash wrote: When doing things like this you always need to coalesce events before drawing. If you're triggering a redraw for every event then you always leave yourself open to problems. The moment that your events come in faster than your redraws can occur, you

Re: Question Regarding the Memory Address of Objects

2008-12-20 Thread Scott Ribe
> An NSMapTable can be configured to give either reasonable behavior > (strong or zeroing weak reference) so use that instead. Or, in this special case, simply make sure that the dictionary is only used while the controller is live--especially easy if the dictionary is a private field of the contr

selectionShouldChangeInTableView called twice

2008-12-20 Thread Andre Masse
Hi, I'm using a master/detail view in my application. If the user select another row in the master table and the detail has been modified, I want to present an alert to save, cancel or return to detail. I'm not using binding here, only datasource and delegate methods. So in - selectionShou

NSBezierPath

2008-12-20 Thread Amr Nashaat
Hi, does anyone knows how can I use the NSBezierPath function to create a circle? thanx. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-de

Re: NSBezierPath

2008-12-20 Thread Randall Meadows
On Dec 20, 2008, at 11:35 AM, Amr Nashaat wrote: does anyone knows how can I use the NSBezierPath function NSBezierPath is not a "function", but anyway... to create a circle? + (NSBezierPath *)bezierPathWithOvalInRect:(NSRect)aRect where aRect describes a square. _

Re: Optimizing NSRectFill

2008-12-20 Thread Kyle Sluder
On Sat, Dec 20, 2008 at 12:18 PM, Michael Ash wrote: > A simple way to do this is to avoid calling setNeedsDisplay: (or its > friends) directly from your event handler. Instead start a timer with > some suitably small interval, and set a flag. If the flag is already > set, don't start the timer, i

Re: toolbar to view gradient displaying correctly only sometimes?

2008-12-20 Thread Benjamin Dobson
It certainly doesn't blend the toolbar to the toolbar to the window, but I don't see anything else wrong with the gradient. Why do you want to do this anyway? Note that the gradient will always look silly on Tiger. On 20 Dec 2008, at 17:39:16, Chunk 1978 wrote: i have a window with a tool

Find Panel Stopped Working (maybe)

2008-12-20 Thread John Nairn
I have the "Uses Find Panel" checked for the only NSTextView in a window, but it does not use a Find panel. I think it used to use the Find Panel before (but I am not sure). Is there something more that is needed besides checking that box? Some other possibilities: 1. I noticed the items i

Re: MathPaper (Chapter 10) fails

2008-12-20 Thread Kyle Sluder
On Sat, Dec 20, 2008 at 11:28 AM, Richard S. French wrote: > Note that I am using Xcode 2.4.1. I also have the evaluator copied under > MathPaper in targets. Where is it being copied to? (It is under a "Copy Files" phase, correct?). Instead of just printing "path set", try logging the value of

Re: Get notified of fullscreen switch

2008-12-20 Thread Eric Schlegel
On Dec 20, 2008, at 6:49 AM, Joachim Deelen wrote: Hi Eric, thanks for the quick response. "Listening" to the Carbon Event you described did it. The only "disadvantage" is: Now the App depends on Carbon.framework so far it was Cocoa, Quartz, QuartzCore and ScriptingBridge only But,

Re: Find Panel Stopped Working (maybe)

2008-12-20 Thread Kyle Sluder
On Sat, Dec 20, 2008 at 2:10 PM, John Nairn wrote: > 1. I noticed the items in the Find menu were not connected to any actions. I > tried connecting them all to performFindPanelAction: (I could not find any > other options that make sense), but that did not make it work. Looking at TextEdit's Mai

Re: How to use animation for CALayer frame.size attribute?

2008-12-20 Thread Matt Long
I'm hoping that all of the asterisks are just artifacts from a copy/ paste maneuver or something, however, if they are not then you're missing some serious fundamentals. This code will never compile. Let's just assume a copy/paste issue. If you are wanting to animate the size of the frame, u

Re: Find Panel Stopped Working (maybe)

2008-12-20 Thread John Nairn
Thanks Kyle. That did solve it. I am guessing it never worked before and that my original nib file was created before 10.3 and thus did not use the required performFindPanelAction tags. I did wire them to the correct actions, by I assume NSTextView validated according to those tags and sinc

Re: Trackpad multi touch events in Mac OSX

2008-12-20 Thread Scott Anguish
On 20-Dec-08, at 10:56 AM, Andreas Eriksson wrote: Hi, is there a public API to catch the new trackpad multi touch events in Mac OSX? No. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comm

Re: NSBezierPath

2008-12-20 Thread Michael Ash
On Sat, Dec 20, 2008 at 1:35 PM, Amr Nashaat wrote: > Hi, > > does anyone knows how can I use the NSBezierPath function to create a > circle? Have you considered searching the internet? If I take your question and put it verbatim into Google, the very first hit that comes back has sample code tha

Re: Optimizing NSRectFill

2008-12-20 Thread Michael Ash
On Sat, Dec 20, 2008 at 1:51 PM, Kyle Sluder wrote: > On Sat, Dec 20, 2008 at 12:18 PM, Michael Ash wrote: >> A simple way to do this is to avoid calling setNeedsDisplay: (or its >> friends) directly from your event handler. Instead start a timer with >> some suitably small interval, and set a fl

Re: Sorting an NSMutableArray

2008-12-20 Thread Rob Rix
See -sortUsingFunction:context: in NSMutableArray’s documentation. As Ricky Sharp has already mentioned, there’s also -sortUsingSelector:, however if you’re comparing partly with external data you might like having the void * context provided by this method. Sincerely, Rob On 20-Dec-08, at

Re: Optimizing NSRectFill

2008-12-20 Thread Jean-Daniel Dupas
Le 20 déc. 08 à 21:14, Michael Ash a écrit : On Sat, Dec 20, 2008 at 1:51 PM, Kyle Sluder wrote: On Sat, Dec 20, 2008 at 12:18 PM, Michael Ash wrote: A simple way to do this is to avoid calling setNeedsDisplay: (or its friends) directly from your event handler. Instead start a timer wit

Re: Optimizing NSRectFill

2008-12-20 Thread Jean-Daniel Dupas
Le 20 déc. 08 à 22:47, Jean-Daniel Dupas a écrit : Le 20 déc. 08 à 21:14, Michael Ash a écrit : On Sat, Dec 20, 2008 at 1:51 PM, Kyle Sluder wrote: On Sat, Dec 20, 2008 at 12:18 PM, Michael Ash wrote: A simple way to do this is to avoid calling setNeedsDisplay: (or its friends) direct

Re: Text track in QTMovie

2008-12-20 Thread Joe Turner
Okay, I took your suggestions. It seems that my array of characters is the issue. My ByteCount s and other variables have seemingly correct values, but the array of chars' value does not change from before it gets written to. So, I tried a few more ways and no luck. I tried using a UInt8 *c

Re: toolbar to view gradient displaying correctly only sometimes?

2008-12-20 Thread Graham Cox
On 21 Dec 2008, at 4:39 am, Chunk 1978 wrote: is there a reason why my dad's 20 alu iMac 2007 would be displaying this gradient improperly? Many Macs have 6-bit LCD displays, making them incapable of displaying 32-bit colour, which requires 8-bit pixels. Could that be it? You might also

Re: Using runtime functions to match up object types safely when setting properties

2008-12-20 Thread Graham Cox
On 21 Dec 2008, at 4:07 am, Michael Ash wrote: You could build a table, either manually or perhaps with the help of some sort of crazy macro. But there is absolutely no way to get the NSColor out of -(void)setColor:(NSColor*)c at runtime because that info simply isn't there. Yep, I've come t

Re: selectionShouldChangeInTableView called twice

2008-12-20 Thread Graham Cox
On 21 Dec 2008, at 5:23 am, Andre Masse wrote: I'm using a master/detail view in my application. If the user select another row in the master table and the detail has been modified, I want to present an alert to save, cancel or return to detail. Just my 2¢ worth, but this sounds like a ho

Re: Newbie Question: implementing a stack

2008-12-20 Thread Steve Wetzel
On Dec 20, 2008, at Dec 20:12:08 AM, Graham Cox wrote: On 20 Dec 2008, at 4:52 pm, Graham Cox wrote: On 20 Dec 2008, at 3:15 pm, Steve Wetzel wrote: Regarding memory management - does it make more sense to copy the object to be pushed from within the Stack object rather then copying it

Copying Managed Objects from App to Doc MOContext

2008-12-20 Thread Jerry Krinock
My app maintains in its managed object context an array of, say, Potato objects. The potatoes in this central managed object context come and go occasionally -- someone might throw in a new one, or eat one. An archived potato is low in calories, consisting of a half dozen numbers or short

Re: selectionShouldChangeInTableView called twice

2008-12-20 Thread Rob Rix
I'm using a master/detail view in my application. If the user select another row in the master table and the detail has been modified, I want to present an alert to save, cancel or return to detail. Just my 2¢ worth, but this sounds like a horrible UI. If I get interrupted by an alert ev

Re: Newbie Question: implementing a stack

2008-12-20 Thread Graham Cox
On 21 Dec 2008, at 10:52 am, Steve Wetzel wrote: I guess can simply assign the pointer, but if I do, it seems to me I will need an NSMutableArray to hold myObj1... myObj10 (or more). If I do that, what benefit is the stack? I don't really follow your argument. Presumably you decided you

Re: selectionShouldChangeInTableView called twice

2008-12-20 Thread Graham Cox
On 21 Dec 2008, at 11:03 am, Rob Rix wrote: Not to be picky, but Mail’s accounts pane actually works the way he describes. If I select an account, uncheck “Include when automatically checking for new mail” and then select a different account, it asks me if I want to save the changes before

(no subject)

2008-12-20 Thread John Nairn
I had a similar problem and there were serious performance issues with the built-in sorting. I could make it work with sortUsingFunction:context:, but the performance depends significantly on the efficiency of that method (i.e., how much work it takes to interact with that external data). I

Re: selectionShouldChangeInTableView called twice

2008-12-20 Thread Jerry Krinock
On 2008 Dec, 20, at 10:23, Andre Masse wrote: I'm using a master/detail view in my application. If the user select another row in the master table and the detail has been modified, I want to present an alert to save, cancel or return to detail. Back to the original question, I always thoug

Re: Copying Managed Objects from App to Doc MOContext

2008-12-20 Thread Kyle Sluder
On Sat, Dec 20, 2008 at 6:58 PM, Jerry Krinock wrote: > My app maintains in its managed object context an array of, say, Potato > objects. The potatoes in this central managed object context come and go > occasionally -- someone might throw in a new one, or eat one. An archived > potato is low i

Re: Optimizing NSRectFill

2008-12-20 Thread Michael Ash
On Sat, Dec 20, 2008 at 4:47 PM, Jean-Daniel Dupas wrote: > So I think that you're right (and that everything is synchronous) but I also > think that the 'flush results to screen' blocks until the screen is ready > and so limit the number of redraw to the refresh rate of the screen. > If this is e

Re: Newbie Question: implementing a stack

2008-12-20 Thread Michael Ash
On Sat, Dec 20, 2008 at 6:52 PM, Steve Wetzel wrote: > I do see your point Graham but what I am trying to understand is how to work > with the stack if I don't copy the object to put on it. If I simply push > the pointer on the stack, it seems that I have to make a lot of objects in > the code th

Re: Copying Managed Objects from App to Doc MOContext

2008-12-20 Thread Jerry Krinock
On 2008 Dec, 20, at 17:55, Kyle Sluder wrote: This doesn't make sense... you don't store arrays in managed object contexts. Whoops. Indeed, that does not make sense. I should have said that there are potatoes inserted into the app's central managed object context. They're not in an arr

Re: NSTimer help

2008-12-20 Thread Rob Keniger
On 18/12/2008, at 2:20 PM, Andrew Merenbach wrote: Is there a reason to use it in the case that one might instead use - isEqual: or, as was discussed in a recent thread, -isEqualToString: (which was stated, if I recall correctly, to be optimized for speed in the case of strings)? Apologie

Re: selectionShouldChangeInTableView called twice

2008-12-20 Thread Graham Cox
On 21 Dec 2008, at 12:26 pm, Jerry Krinock wrote: On 2008 Dec, 20, at 10:23, Andre Masse wrote: I'm using a master/detail view in my application. If the user select another row in the master table and the detail has been modified, I want to present an alert to save, cancel or return to

Re: selectionShouldChangeInTableView called twice

2008-12-20 Thread Andre Masse
Thanks for your replies guys. This application is a front end to a database with a lot of data entries and deals with legal data. There's a lot of validations going on and data integrity is vital. Normally, the user will save or cancel by clicking a button in the detail view and changes wil

Re: Copying Managed Objects from App to Doc MOContext

2008-12-20 Thread Dave Fernandes
I am doing something very similar to you. I have an application-based library of potatoes, and each document has a copy of some of those potatoes. I did this because the document may be opened on another computer that does not have access to the same library (or as you mention, the library

Re: selectionShouldChangeInTableView called twice

2008-12-20 Thread Andre Masse
On Dec 20, 2008, at 22:00, Graham Cox wrote: If the UI is part of an inspector-type interface, i.e. modeless, then just make the change but do it undoably. Performing the Undo naturally updates any visible UI that matters (KVO/Bindings makes this trivial). The main case where a Save/Cance

Re: Copying Managed Objects from App to Doc MOContext

2008-12-20 Thread Kyle Sluder
On Sat, Dec 20, 2008 at 9:29 PM, Jerry Krinock wrote: > Both. The app-wide MOC has its PSC set to the app-wide PSC, which in turn > has a persistent store in the Application Support folder. OK, good, glad I understood you there. > By UUID, I believe you mean [[[self objectID] URIRepresentation]

Re: Using runtime functions to match up object types safely when setting properties

2008-12-20 Thread Andrew Farmer
On 20 Dec 08, at 02:16, Graham Cox wrote: On 20 Dec 2008, at 8:05 pm, Andrew Farmer wrote: However, I think you've overengineering things here. The standard runtime introspection methods, like [NSObject class] and [NSObject isKindOfClass:], should be more than enough to implement this sort