CoreData regression or performance problem, anyone?

2014-11-12 Thread Vincent Habchi
Folks,

the sqlite version installed on OS X machines has been bumped to 3.8.x in OS X 
10.10. This apparently had the unfortunate side (or collateral) effect of 
plummeting performance of some requests (specifically, some Macports related 
database operations now take forever while they were fairly quick on 10.9).

I was just wondering if some of you, in their applications using SQLite/Core 
Data, had noticed such a severe loss of performance.

Thanks,
Vincent


___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: CoreData regression or performance problem, anyone?

2014-11-12 Thread Vincent Habchi
Jens,

> If you're using CoreData I'm not sure if you'll be able to fix your database 
> schema, since presumably CoreData manages it and not you. So I'm not sure how 
> you'd work around the problem. Good luck!

In fact, the Macports search engine is not, so I guess we’ll figure out a way 
to fix this correctly. But I wanted also to warn every possible user of Core 
Data that they might experience regression without any evident reason.

Cheers!
Vincent


___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

CALayer's removeFromSuperlayer processing time

2010-03-31 Thread vincent habchi
Hi there,
I'm back working on my small GIS after a while fighting with urgent things. 

My today concern is this: at some point, I must replace a CALayer by another. I 
therefore use
[theCALayerIWantToRemove removeFromSuperlayer]

However, I register quite a significant delay (sometimes 6 to 10 seconds) 
between this call and the actual call to [theCALayerIWantToRemove release]. Is 
this normal (due to some autorelease pool being drained?)? 

Thanks a lot,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CALayer's removeFromSuperlayer processing time

2010-03-31 Thread vincent habchi
Hi Dave,

>> However, I register quite a significant delay (sometimes 6 to 10 seconds) 
>> between this call and the actual call to [theCALayerIWantToRemove release]. 
>> Is this normal (due to some autorelease pool being drained?)? 
> 
> It is normal in terms of us making no guarantees as to the timing between a 
> layer being removed from its super layer and that layer being released by its 
> super layer.
> 
> Is there a specific issue you are trying to debug?

For some unknown reason (I am investigating on that), the new layer I create to 
replace the old won't be displayed before the old get deallocated. So I get a 
visible glitch while the old layer is removed from screen but not yet 
deallocated.

Thanks for your help,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CALayer's removeFromSuperlayer processing time

2010-03-31 Thread vincent habchi
Kyle,

> For all you know or care the layer may never be released at all. All
> you can do is balance your own retains and releases as appropriate.

Okay, if I understand correctly, the only guarantee you have is that the layer 
is erased from screen, but nothing else.

Thanks a lot!
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CALayer's removeFromSuperlayer processing time

2010-04-01 Thread vincent habchi
Le 31 mars 2010 à 22:02, vincent habchi a écrit :

> For some unknown reason (I am investigating on that), the new layer I create 
> to replace the old won't be displayed before the old get deallocated. So I 
> get a visible glitch while the old layer is removed from screen but not yet 
> deallocated.

Okay, I've solved this using a timer.

Thanks a lot,
Vincent


___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSLayerStack/NSArrayController/NSButton action puzzle

2010-04-01 Thread vincent habchi
Hi there,

sorry for maybe asking a silly question, I could not get a clue elsewhere.

I have a NSLayerStack whose subviews represent a certain kind of object stored 
in a list controlled by a NSArrayController. Each of these subviews features 
two buttons, one is of the "Momentarily push-in" type, and the other is 
"Push-in push-out".

While I was able to bind the action of the "Momentarily push-in" button to some 
selector of the "representedObject", I cannot do that for the "Push-in 
Push-out": the option is lacking in IB. Do you have any idea of a workaround, 
or am I missing something?

Thanks!
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSCollectionView/NSArrayController/NSButton action puzzle

2010-04-01 Thread vincent habchi
Kyle,

> Um, what is an NSLayerStack?

An April fool? :) No, seriously, sorry, I was a bit tired: it's a 
NSCollectionView that I subclassed and I called it LayerStack. I updated the 
subject accordingly. 

> Wire up the action to some other method that looks at the view's
> represented object and does whatever it needs to do?

Not possible. Each subview must deliver the action precisely to the object they 
represent, so static bindings are impossible here.

Sorry again for the confusion, and thanks for your answer!
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


"Toll free" bridge from NSAttributedString * to CFAttributedStringRef

2010-04-08 Thread vincent habchi
Hi there,

I've been fiddling with NSAttributedString lately, and the way to display them 
through Core Text. In the docs, I've read that NSAttributedString and 
CFAttributedStringRef were supposed to be "toll free" bridged; I assumed that 
meant that one could be used in lieu of the other with (or maybe even without) 
a simple cast.

But I found this is not true. Specifically, I was getting strange errors like 
"CFSet[Stroke|Fill]ColorFromColor : invalid context 0x0" each time I printed my 
NSAttributedString by CTLineDraw(), although I had a perfectly valid context. 
The glyph were drawn, but always in black, while I was attempting to get 
another color via the NSForegroundColorAttributeName. At the end, I had to 
replace the pair (NSColor, NSForeground…) by a (CGColorRef, kCTForeground…), 
and now it works.

Is that supposed to be a "normal" behavior, did I misunderstand the meaning of 
"toll free", or is it a bug?

Thanks!
Vincent

PS : conversely, I found that NSFont * and CTFontRef are really 
equivalent.___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: "Toll free" bridge from NSAttributedString * to CFAttributedStringRef

2010-04-08 Thread vincent habchi
Glenn,

> NSAttributedString and CFAttributedStringRef "the data structure" are toll 
> free bridged, but that just means that the objects themselves can be 
> interchanged.  The problem is that, like an NSDictionary, they can store 
> arbitrary objects that may not be toll free bridged - in this case, NSColor 
> and CGColorRef are not interchangeable, nor are the keys NSForegroundColor 
> and kCTForegroundColorAttributeName documented as the same.
> 
> So CTLineDraw expects to have the color specified as a CGColorRef in 
> kCTForegroundColorAttributeName, while drawString: expects to have the color 
> specified as an NSColor in NSForegroundColor.

So what's the point in saying that both NSAttributed… and CFAttributed… are 
toll free bridged, if you cannot use one for another? I find it misleading.

Cheers!
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


CFRunLoopStop exception

2010-04-08 Thread vincent habchi
Hi,

I was running quite an intensive test on creating/freeing threads running 
RunLoops, and I got a rather unexpected crash while executing CFRunLoopStop ():

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0002, 0x
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   com.apple.CoreFoundation0x7fff801da6d1 CFRunLoopWakeUp + 129
[…]

Since I had 34 other threads active, I wonder if there is any practical 
threshold on the number of Run Loops Snow Leopard can manage?

Thanks,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CFRunLoopStop exception

2010-04-08 Thread vincent habchi
Well, I forgot to mention that each thread is responsible for the drawing of a 
CATileLayer, if that matters.

Vincent

___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: "Toll free" bridge from NSAttributedString * to CFAttributedStringRef

2010-04-08 Thread vincent habchi
Adam,

> You need to have a current NSGraphicsContext for NSColor (and possibly other) 
> attributes.  This is pretty easy, as in the following snippet from my own 
> code:
> 
>[NSGraphicsContext saveGraphicsState];
>[NSGraphicsContext setCurrentContext:[NSGraphicsContext 
> graphicsContextWithGraphicsPort:ctxt flipped:NO]];
> 
>CTFrameDraw(frame, ctxt);
>CGContextFlush(ctxt);
>CFRelease(frame);
> 
>[NSGraphicsContext restoreGraphicsState];

Nice, I must admit I hadn't think about NSGraphicsContext at all, having a 
valid CGContext. I'll try this. Thanks at lot!

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CFRunLoopStop exception

2010-04-08 Thread vincent habchi
Jesper,

> FYI: Remember that corefoundation is open source. 10.6.2 can be found at: 
> http://www.opensource.apple.com/source/CF/CF-550.13/

Thanks for the link, very instructive.

> void CFRunLoopWakeUp(CFRunLoopRef rl) {
> CHECK_FOR_FORK();
> #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
> kern_return_t ret;
> /* We unconditionally try to send the message, since we don't want
>  * to lose a wakeup, but the send may fail if there is already a
>  * wakeup pending, since the queue length is 1. */
> ret = __CFSendTrivialMachMessage(rl->_wakeUpPort, 0, MACH_SEND_TIMEOUT, 
> 0);
> if (ret != MACH_MSG_SUCCESS && ret != MACH_SEND_TIMED_OUT) {
>   HALT;
> }

Okay, so that means it is impossible to ask a run loop to stop while it is 
being messaged to wake up. Practically, this might not be a severe threat, but 
when you begin to create/destroy threads at small intervals (say, 50 ms), the 
collision seems to be inevitable (especially since I also use timers to wake up 
the loops). I wonder why the queue has only a single entry.

Anyhow, thanks again!
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CFRunLoopStop exception

2010-04-09 Thread vincent habchi
Le 9 avr. 2010 à 08:08, Greg Parker a écrit :

> In this circumstance, mach_msg() will block if the queue is full, and either 
> succeed later or time out. Neither of those paths should end up at HALT. 
> (mach_msg() may do other things in other circumstances.)
> 
> Presumably mach_msg() returned something other than MACH_MSG_SUCCESS or 
> MACH_SEND_TIMED_OUT in your example. What's in register rax in your crash log?

rax: 0x1003

So I suppose it's what somebody mentioned before: the runLoop has already died. 
When the runLoop is exited, my code resets the CFRunLoopRef to NULL: under this 
condition, no further call to CFRunLoopStop is possible. But I assume the 
extraneous call happened exactly between the exit of the run loop and the reset 
of the pointer (at first sight, I see no reason why CFRunLoopStop would be 
called twice, but…).

I now protect the call to CFRunLoopStop() by a flag that I set to true when the 
function is called for the first time, so it might solve this issue.

Thanks for helping,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CFRunLoopStop exception

2010-04-09 Thread vincent habchi
Steve,

> Pulling these out, it may be time to look at WAYRTTD.
> 
> Creating/destroying lots of threads to render tiles seems massively 
> inefficient for lots of reasons and Mac OS X has much better mechanisms for 
> this.
> 
> Depending on what minimum OS requirements you might get much better results 
> using Grand Central Dispatch or any of a number of appropriate approaches 
> like Operation Queues or Dispatch Queues, down to managing your own pool of 
> worker threads with a number of threads on the order of the number of cores 
> available.

Thanks for the hint. As a first step, I try to get everything working. I was 
planning to dig into GCD at a later point, when every obvious bug will be fixed 
and a minimum reached. I might also look at OpenCL for a variety of things.

Cheers,
Vincent

___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSArrayController in entity mode and permutations (CoreData question)

2010-04-12 Thread vincent habchi
Hi again!

I'd like to change the place of a NSManagedObject stored in a NSArrayController 
in entity mode (after a drag'n drop operation). I didn't find any suitable 
primitive, so I decided to go something like "removeAtSomeIndex" and then 
immediately after "insertAtSomeOtherIndex".

However, it does not work: it seems as soon as an object is removed from the 
array, core data is told to unlink it, so, at the end of the permutation, I end 
up with an array full of object that get removed in core data at a later point, 
and after a while I get faults with non-existent objects.

Is there any trick to solve this knot?

Thanks a lot,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSArrayController in entity mode and permutations (CoreData question)

2010-04-12 Thread vincent habchi
Quincy,
(sorry for the double answer)

> This is likely NOT a Core Data question. Most likely you're not doing your 
> memory management quite correctly. Look here under the heading "Mutable 
> Arrays":
> 
>   
> http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Collections/Articles/Arrays.html#//apple_ref/doc/uid/2132-BBCCJBIF
> 
> In particular, it says:
> 
> "In a managed memory environment, when an object is removed from a mutable 
> array it receives a release message. This means that if an array is the only 
> owner of an object, then the object is deallocated when it is removed. If you 
> want to use the object after its removal, you should therefore typically send 
> it a retain message before it’s removed from the array."

Right. So I inserted the object into another mutable array (that store the 
permuted objects) *before* actually deleting and reinserting it. Same behavior. 
To be more specific, everything works right, up to the point where I saved the 
context and bing, all the objects disappear. That leads me, on the contrary, to 
believe that memory management is okay, but core data references go away.

Anyhow, I'm trying to solve this using proxy objets that I manipulate instead 
of the managed objects.

Vincent

 ___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSArrayController in entity mode and permutations (CoreData question)

2010-04-12 Thread vincent habchi
Quincey,

thanks a lot

> Surely it would be more robust to make the order explicit in your data model 
> (with a transient property if the order really is transient) and let the 
> array controller keep the displayed content sorted according to that order?

Sure, I could do that. In fact I have done it: This order is not a property of 
the inserted object, but of one liked therewith. But tell me, would 
drag-and-drop work by just rearranging an object ID?

Besides, the proxy solution has one advantage: since the object in the 
NSArrayController reacts to actions performed on buttons linked to it, I think 
it is better to have code in the proxy object rather than on the NSManaged one, 
that gets overwritten every time I alter it, even slightly. What do you think?

Thanks again,
Vincent


___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSArrayController in entity mode and permutations (CoreData question)

2010-04-13 Thread vincent habchi
Le 12 avr. 2010 à 22:22, Kyle Sluder a écrit :

> On Mon, Apr 12, 2010 at 12:12 PM, vincent habchi  wrote:
>> Besides, the proxy solution has one advantage: since the object in the 
>> NSArrayController reacts to actions performed on buttons linked to it, I 
>> think it is better to have code in the proxy object rather than on the 
>> NSManaged one, that gets overwritten every time I alter it, even slightly. 
>> What do you think?
> 
> You're advocating an explicit violation of MVC. Why not instead move
> the code into the model where it belongs and have the controller ask
> the model to perform the operation?

That's eventually what I did. I reverted to my first schema, and let go the 
proxies. Thanks for pointing that it was a *really* bad idea. More under the 
answer to Quincey.

Vincent


___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSArrayController in entity mode and permutations (CoreData question)

2010-04-13 Thread vincent habchi
Le 12 avr. 2010 à 23:17, Quincey Morris a écrit :

> I think I'm confused now about what scenario we are talking about. Are you 
> saying that the object you insert with [NSArrayController insertObject...] is 
> *not* a NSManagedObject, but is a proxy object that is linked to the 
> NSManagedObject? Or are you referring to the NSArrayController itself as a 
> proxy object?

Forget that story of proxies that was a botch. I reverted to the first scheme, 
followed your idea to implement a NSNumber attribute and a sort predicate. 
Well, it took me a whole day to figure out a clean algorithm to handle the 
renumbering caused by the drag-and-drop operation, but it works now, and is not 
plagued by any side effect anymore.

If you want to know a bit more, the managed object represents a "geographical 
data layer" (e.g.: roads, buildings, rivers, etc.). The user selects which gets 
drawn first, then which gets drawn over the first, etc. up to the highest 
layer, that lies atop all the others. This "ordered stack" is displayed on 
screen through a NSCollectionView whose contents observe the NSArrayController 
arrangedObjects. The user can drag and drop the NSView in the NSCollectionView 
to modify the drawing order.

Thanks a lot for your precious help, you and Kyle.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Text file

2010-04-15 Thread vincent habchi
Hi,

> 0x91dc507e  <+0334>  call   0x91e68a50 
> 0x91dc5083  <+0339>  mov%esi,(%esp)
> 0x91dc5086  <+0342>  call   0x91ebf566 
> 0x91dc508b  <+0347>  lea-0x80(%ebp),%esi
> 0x91dc508e  <+0350>  mov%esi,(%esp)
> 0x91dc5091  <+0353>  call   0x91ebfb36 
> 0x91dc5096  <+0358>  mov%esi,(%esp)
> 0x91dc5099  <+0361>  call   0x91ebf61a 
>> 0x91dc509e  <+0366>  test   %eax,%eax

If you mean that your program crashed on this very instruction, it should not 
happen. This is just a test to figure out if the EAX register is or is not 
null. Crash usually happen when you access protected memory or try to execute 
an unknown instruction...

Vincent


___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


HUD window widgets

2010-04-16 Thread vincent habchi
Hi again,

I'd like to add some widgets in a HUD window, like, for example, a small pop-up 
button, with a non-white menu background, small non-black text, etc. How can I 
achieve this? By subclassing NSPopUpButtonCell?

Thanks,
Vincent


___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: HUD window widgets

2010-04-17 Thread vincent habchi
> I know of three frameworks that provide controls for use in HUD windows (in 
> order of recommendation):
> 
> BWToolkit - http://www.brandonwalkin.com/bwtoolkit/
> BGHUDAppKit - http://www.binarymethod.com/bghudappkit/
> HMBlkAppKit - http://shiira.jp/hmblkappkit/en.html

Thanks a lot to both. BWToolkit seems fine for what I intend to do.

Cheers
Vincent

___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Creating temporary NSManagedObjects

2010-04-26 Thread vincent habchi
Hi to all,

I need to create a short-lived NSManagedObject; ideally, I'd want it not to be 
inserted in the Core Data underlying framework, because I need it only during 
the display of an auxiliary window, and I don't want it saved anyway. I've 
tried a simple alloc, an alloc and init, but to no avail: It seems to create 
only the proxy object. Is there a way to do that?

Thanks,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Creating temporary NSManagedObjects

2010-04-26 Thread vincent habchi
Jack,

> What you want to do, probably, is create an object that doesn't belong
> to a context (the context is what ends up saving your object to a data
> store).  You should be able to do something like this:
> 
> // assuming your app delegate contains the "managedObjectModel" method, which
> // the standard Xcode-generated CoreData app typically does
> NSManagedObjectModel *managedObjectModel = [[NSApplication delegate]
> managedObjectModel];
> NSEntityDescription *entity = [[managedObjectModel entitiesByName] 
> @"MyEntity"];
> id obj = [[NSManagedObject alloc] initWithEntity:entity
> insertIntoManagedObjectContext:nil];

So, just replacing the MOC by nil. I have not tried that, I admit.

> BTW the docs for NSManagedObject clearly state that
> "initWithEntity:insertIntoManagedObjectContext:" is the designated
> initializer to use for creating instances, and that you shouldn't just
> call "init".

Yes. But, at the same time, no doc on Core Data, whether Apple written or not, 
seems to talk about "temporary" objects, other than transient. Therefore, one 
might also infer that "initWithEntity:insertIntoManagedObjectContext:" is the 
designated initializer as far as you want your object to be inserted into the 
MOC…

Cheers, and thanks a lot for the idea!
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Creating temporary NSManagedObjects (PS)

2010-04-26 Thread vincent habchi
Le 26 avr. 2010 à 11:04, Jack Nutting a écrit :

> // assuming your app delegate contains the "managedObjectModel" method, which
> // the standard Xcode-generated CoreData app typically does
> NSManagedObjectModel *managedObjectModel = [[NSApplication delegate]
> managedObjectModel];
> NSEntityDescription *entity = [[managedObjectModel entitiesByName] 
> @"MyEntity"];
> id obj = [[NSManagedObject alloc] initWithEntity:entity
> insertIntoManagedObjectContext:nil];

By the way, how do you delete these objects with a null MOC, since you are 
supposed to call [MOC deleteObject:]?
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Creating temporary NSManagedObjects

2010-04-26 Thread vincent habchi
Hi Joanna,

> Do you really need an NSManagedObject?
> Do you ever need to store instances of this particular class?

Yes. That NSObject holds some properties associated with a graphical layer. I 
have a lot of them, that I classically save in order to be able to restore the 
state of the application at launch. Now, to highlight a specific item on a 
given layer, I create a temporary layer, that I destroy once the user has 
identified the highlighted item. To keep the drawing code orthogonal, I have to 
create that temporary NSObject I mentioned, which is needed by my 
drawInContext: method. 

I hope it is a bit clearer, despite my rusty English.
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Creating temporary NSManagedObjects (PS)

2010-04-26 Thread vincent habchi
Le 26 avr. 2010 à 15:50, Jack Nutting a écrit :

> Well I haven't actually tried it yet, so don't thank me yet!  ;)  The
> docs for "initWithEntity:insertIntoManagedObjectContext :" do include
> the text "If context is not nil, this method..." though, which seems
> to imply that you should be able to send it a nil context. I really
> should try this out myself.

It seems to work. I've to write a few more lines and I'll let you know.
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Creating temporary NSManagedObjects (PS)

2010-04-26 Thread vincent habchi
Le 26 avr. 2010 à 15:50, Jack Nutting a écrit :

> Well I haven't actually tried it yet, so don't thank me yet!  ;)  The
> docs for "initWithEntity:insertIntoManagedObjectContext :" do include
> the text "If context is not nil, this method..." though, which seems
> to imply that you should be able to send it a nil context. I really
> should try this out myself.

It works. I found myself forced to copy more objects (because when two MOC are 
different you can't establish cross-MOC relationships), but it works allright. 
Now, I've not checked whether the objects get actually freed with a release: 
call. I'll see that with Instruments.

V.___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSManagedObject, retain count and dealloc:

2010-04-26 Thread vincent habchi
Hi again,

I am unable to see a NSManagedObject go through the dealloc: method, even after 
its removal from the MOC. It seems these objects are created after a 
initWithEntity:insertIntoMOC: with an initial retain count of 2, and, of 
course, it is impossible to make the retain count (by honest means) drop below 
2. Is this normal expected behavior?

Thanks,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSManagedObject, retain count and dealloc:

2010-04-26 Thread vincent habchi
Le 27 avr. 2010 à 00:18, Kyle Sluder a écrit :

> If your object is holding on to some resource which you need it to
> release, write a method called -invalidate or -letGoOfImportantThing
> or something and call that at a deterministic time.

Understood. I'll do that. I must admit I have a tendency to free resources at 
dealloc:, but if this does not happen, I guess I have little other choice.

Cheers
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: white screen windows at first

2010-04-27 Thread vincent habchi
Le 26 avr. 2010 à 23:35, Bill Appleton a écrit :

> hi all,
> 
> when my windows are first shown there is no drawing inside, they are white
> 
> but when i slowly move the mouse over to the close box and the close box
> responds to the mouse hover suddenly they draw their content properly
> 
> does this ring any bells with people? i'm not sure where to look in the docs
> for this one

Darn, I got that kind of behavior with my CALayers a while ago. They would not 
draw unless I moved the layers or zoomed on them. Did you try to look at 
background properties? Are your views layer backed?

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Creating temporary NSManagedObjects

2010-04-27 Thread vincent habchi
Quincey,

> Notwithstanding the discussion in this thread so far, I don't quite 
> understand why you wouldn't do this the easy way: create a NSManagedObject in 
> your managed context, and delete it when you're done with it.
> 
> The documentation explicitly describes the managed context as a "scratch 
> pad", where objects can come and go as you need them.

There is a simple reason: the objects in the Managed object context get 
"represented" on a third window, whose contents are drawn from an Entity mode 
NSArrayController that prepares its contents automatically. If I add my 
temporary object to the MOC, it automatically gets fetched and displayed in 
that window the very moment it is inserted; that's what I wanted to avoid 
because it is confusing and thus undesirable.

Vincent


___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: menu madness with retain count

2010-04-27 Thread vincent habchi
Le 27 avr. 2010 à 20:42, Jens Alfke a écrit :

> What you "own" are references. If you call a method that creates a reference, 
> like +alloc, -retain or -copy, then you now own a reference to that object. 
> For as long as you own that reference, the object will stay around. When you 
> don't need the object anymore, you have to release that reference by telling 
> the object to -release or -autorelease.
> 
> [And +1 on ignoring -retainCount. The only time this method is useful is if 
> you are in gdb debugging some kind of tricky refcounting error; and even then 
> you have to take its value with a grain of salt due to the effect of the 
> autorelease pool.]

Yet, at the same time, you may want the dealloc: method to trigger some events. 
For example, if you have a CALayer that holds various sublayers, and that 
CALayer goes away, you may want all the sublayers to go away at the same time. 
Yet, this is impossible if some other object around locks a reference to the 
sublayers.

By the way, how are exactly multiple calls to [object autorelease] handled by 
the pool? Does this give rise to as many calls to release: as they are 
autorelease references stored, or does the pool directly adjust the retain 
count?

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: menu madness with retain count

2010-04-27 Thread vincent habchi
Le 27 avr. 2010 à 21:21, Scott Ribe a écrit :

>> By the way, how are exactly multiple calls to [object autorelease] handled 
>> by the pool? Does this give rise to as many calls to release: as they are 
>> autorelease references stored, or does the pool directly adjust the retain 
>> count?
> 
> Why would you care?

Because earlier in this afternoon I decided to trace the retain/release 
messages sent to an object by overriding the respective methods and have them 
write the retain count before calling super methods. I registered most curious 
behaviors, for example objects released while the last time their retain count 
was printed it was equal to 2. No 1, no 0. That's why I asked, just to know if 
autorelease does not short-circuit the traditional release: call by accessing 
the retain count directly.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: menu madness with retain count

2010-04-27 Thread vincent habchi
Le 27 avr. 2010 à 21:17, Jens Alfke a écrit :

> Remember that in a ref-counted (or GC'd) system you can't force an object to 
> deallocate (even 'self'.) The deallocation is under control of all the other 
> objects that have references, and the runtime itself. So you should never put 
> any code into -dealloc or -finalize that absolutely has to run at a 
> particular time.

Yes, I've learned that the hard way. ;)
Cheers
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: menu madness with retain count

2010-04-27 Thread vincent habchi
Le 27 avr. 2010 à 21:57, Jens Alfke a écrit :

>> I registered most curious behaviors, for example objects released while the 
>> last time their retain count was printed it was equal to 2. No 1, no 0. 
>> That's why I asked, just to know if autorelease does not short-circuit the 
>> traditional release: call by accessing the retain count directly.
> 
> That sounds like an optimization in the runtime to avoid a couple of 
> message-sends. You shouldn't override -retain or -release or make assumptions 
> about how many times they're called; those are implementation details.

That's what I inferred too, and that's why I supposed the autorelease pool 
pokes directly somehow in retain counts to rise performance, but it may be, as 
you say, some optimizing behavior at runtime.

Ok, forget it. Extremely interesting, but I feel this thread is, as we say in 
French, a sea snake: we might never see its end.

Good night and thanks again!
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Selecting an object based on the value of one of its attributes

2010-04-27 Thread vincent habchi
Le 28 avr. 2010 à 04:37, Lynn Barton a écrit :

> Newbie question: Consider an array of dictionary objects, all of the same 
> class. One of the ivars of that class is an NSString which is unique for each 
> instance. Does there already exist a method that will identify the one 
> dictionary object that has a given value of that ivar, without me having to 
> write code to examine all of the objects one by one? 

Use a hash code. That's the way NSDictionary class search for keys. It is way 
faster than simple linear search, especially if you have thousands of elements. 
But it is more code and memory expensive.

Vincent

___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: white screen windows at first

2010-04-28 Thread vincent habchi
Bill,

> my windows are NSBackingStoreBuffered 
> is that what you mean by background property? i am just using a subclassed 
> NSView & a CGContext for drawing

Yes. Please verify that you set the opaque property of your backing layer to 
YES : [[self layer] setOpaque:YES], otherwise you might get strange results.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: white screen windows at first

2010-04-28 Thread vincent habchi
Le 28 avr. 2010 à 10:10, Paul Sanders a écrit :

>> this problem must be because i am using core graphics

There is no problem using Core Graphics, especially if your NSView is backed by 
a CALayer. I do that routinely on the small GIS I try to develop.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Woes with an NSBox

2010-04-28 Thread vincent habchi
HI there,

I have a standard NSBox inside a NSView. I set its border radius and width all 
right.
But when I enable backing layer, the border disappear. Is this normal?

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: white screen windows at first

2010-04-29 Thread vincent habchi
Le 28 avr. 2010 à 20:29, Bill Appleton a écrit :

> this appears to only work from inside the drawRect routine, if i get here 
> from some other event it doesn't work
> 
> so is it "legal" to draw on an NSWindow from some other event? 
> if not, what the heck does QDEndCGContext do that makes it work?

If I remember correctly what David Duncan said here a while ago, graphics 
rendering in Core graphics, and maybe also in Cocoa, is heavily dependent on 
the Run loop. Normally, when you want to recache and redraw a layer, you set 
needsDisplay to YES (or just call - setNeedsDisplay: on a CALayer), and 
-drawRect or -drawInContext: gets called when the current event finishes and 
the Run loop regains control. I am not sure it is legal to draw outside this 
window. That's why if you want to redraw in background under the control of a 
"display" thread, that thread must set up a run loop of its own, or nothing 
gets drawn at all.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSKeyedArchiver and NSPoints

2010-04-29 Thread vincent habchi
Le 29 avr. 2010 à 05:49, Michael Ash a écrit :

> Actually, while there are finite decimal numbers with no finite binary
> representation, the reverse is not true. Every binary number can be
> represented by a finite number of decimal digits. I believe this is
> because 2 is a factor of 10. To prove it to yourself, just take

True. For example, if we were to use trinary numbers, 0.1 would equal to 1/3, 
which has no finite decimal representation. So, thanks Nature for having given 
us 10 fingers and not 9 or worse 11.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSTableView sort with a data source (silly question ?)

2010-05-03 Thread vincent habchi
Hi,

this might be a silly question but, before doing any further implementation, 
and having found no definite answer, I dare ask it. Is there a way to sort the 
contents of a NSTableView whose data is provided by a data source, besides 
sorting at the source itself (via a suitable query)?

Thanks,
Vincent

___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTableView sort with a data source (silly question ?)

2010-05-03 Thread vincent habchi
Le 3 mai 2010 à 17:08, Graham Cox a écrit :

>> this might be a silly question but, before doing any further implementation, 
>> and having found no definite answer, I dare ask it. Is there a way to sort 
>> the contents of a NSTableView whose data is provided by a data source, 
>> besides sorting at the source itself (via a suitable query)?
> 
> You provide sorted data to the table through the data source.

Ok, that's what I was prepared to do.

> But the table can provide sort descriptors back to you to do this, allowing 
> you to click table headers to pick how the data is sorted. Since the table is 
> a view, of course it is your responsibility to provide the data in a sorted 
> form. Responding to a change in sort descriptors and then actually performing 
> a sort is two lines of code.

Well, ideally yes. In my case, it involves adding the selector to respond to 
the click, and append an auxiliary clause to a SQL request (SORT BY xxx 
ASC/DESC) and reload data. It's not two lines, but I agree it is not much work 
either.

Thanks for confirming my opinion!
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Strange NSView/NSWindow behavior

2010-05-04 Thread vincent habchi
Hi again, again, and… (let's be short :))

I have a NSView in a NSWindow. That NSView handles mouse events (mouseDown:, 
Dragged:, Up:). But, to my great astonishment, the event propagates through the 
underlying window, so that when I drag inside the view, the window also moves. 
How come? Any idea?

Thanks a lot,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Strange NSView/NSWindow behavior

2010-05-04 Thread vincent habchi
Le 4 mai 2010 à 20:26, Greg Parker a écrit :

> On May 4, 2010, at 11:18 AM, vincent habchi wrote:
>> Hi again, again, and… (let's be short :))
>> 
>> I have a NSView in a NSWindow. That NSView handles mouse events (mouseDown:, 
>> Dragged:, Up:). But, to my great astonishment, the event propagates through 
>> the underlying window, so that when I drag inside the view, the window also 
>> moves. How come? Any idea?
> 
> Keeping it short: look up -[NSView mouseDownCanMoveWindow]. Override it to 
> return NO if you never want a click in the view to drag the window.

But, if I am not mistaken, when the event is caught and handled, it should not 
propagate further without a call to [super mouseXXX:event], no?

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Strange NSView/NSWindow behavior

2010-05-04 Thread vincent habchi
> Keeping it short: look up -[NSView mouseDownCanMoveWindow]. Override it to 
> return NO if you never want a click in the view to drag the window.

Thanks a lot, by the way! :)
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: subclass overwriting superclass ivar

2010-05-26 Thread vincent habchi
Le 26 mai 2010 à 13:40, jonat...@mugginsoft.com a écrit :

> A subclass ivar is apparently overwriting a super class ivar.
> When an instance of MGS_B sets stderrData the super class ivar tempFilePath 
> gets overwritten.

If I am not mistaken, if your superclass ivar is private (!= protected), it 
cannot be accessed from its subclasses. Thus, the compiler can choose to reuse 
part of the heap dedicated to private variables to implement subclasses own 
private ivars.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: subclass overwriting superclass ivar

2010-05-26 Thread vincent habchi
Le 26 mai 2010 à 14:22, Graham Cox a écrit :

> I'm pretty sure you are mistaken. If this were even remotely true, object 
> programming would be impossible.
> 
> @private only declares the visibility of an ivar to its subclasses, it does 
> not give the compiler carte blanche to write over anything it fancies.

Hmmm... Let's say you have a class A with a private variable "priv" and b a 
pointer to a subclass of A. Is:

[(A *)b priv]

legal?

Now, admitting B never accesses any of A variables, can the compiler optimize 
space by throwing away all A private variables?

Vincent

PS: thanks for this "carte blanche" 
:)___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: subclass overwriting superclass ivar

2010-05-26 Thread vincent habchi
Le 26 mai 2010 à 14:53, Graham Cox a écrit :

> 
> On 26/05/2010, at 10:41 PM, vincent habchi wrote:
> 
>> Hmmm... Let's say you have a class A with a private variable "priv" and b a 
>> pointer to a subclass of A. Is:
>> 
>> [(A *)b priv]
>> 
>> legal?
> 
> 
> No. It's not legal syntax for accessing an ivar in any case - square brackets 
> invoke a method:- [instance method]. 

Granted. I assumed there was a getter defined. That's because, AFAIC, I almost 
always synthesize ivars, so they become regular attributes.

> Perhaps you could ask is:
> 
> (A*)b->priv legal?

Yes. Indeed.

> Depends. If priv is @private it is invisible to code other than within the 
> methods of class A itself, so if this code lived inside such a method it 
> would work, otherwise it would not. I don't think the cast makes any 
> difference.

So, tell me if I'm wrong, but I infer from your answer that whatever I can do, 
there is no means for a subclass A' to access any private variable of its 
ancestor.

> But this is not getting to the problem that the OP is having, which AFAICS is 
> unrelated to @private. @private is a Good Thing™ - often worth using.

Well, as a regular Python code writer, I've never missed @private (or even 
@protected) declarations. I fail anyhow to grasp the relevancy of @private 
vis-à-vis @protected: It seems logical to me that subclasses be granted access 
to all ancestor attributes.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: subclass overwriting superclass ivar

2010-05-26 Thread vincent habchi
Le 26 mai 2010 à 15:24, Jean-Daniel Dupas a écrit :

> Who knows what a class does when you set an ivar using the accessor. It would 
> badly break encapsulation principle.
> For example, what would append if a NSView subclass change the view frame by 
> accessing the _frame ivar directly ? 

You are right. But this is (to me) more relevant to good coding principles. 
I've never programmed in PyObjC, but it should be interesting to have the 
advice of someone who does.

Anyhow, thanks to all for pointing out the flaw in my reasoning.
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: subclass overwriting superclass ivar

2010-05-26 Thread vincent habchi
Jens,

> I think you’re confusing an inaccessible variable with an unused variable. 
> Those are very different concepts. For example, NSView’s _frame instance 
> variable is inaccessible from any subclass, but the variable is of course a 
> crucial part of the view’s state and is accessed by lots of methods in NSView 
> itself.

Okay, thanks for this and your enlightening further comments. I've never 
touched Ruby, but I feel all right with Python :)

At the same time, I remember having this kind of weird behavior (I mean, one 
variable unexpectedly written) when that variable has been (unexpectedly) 
released, and its space is reused by some other variable.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Erasing drawn content

2010-06-09 Thread vincent habchi
Oops, wrong email address, I try again:

> Pity, I like the idea of more bee-based metaphors in APIs (or Apis). It could 
> be known as Bee-OS.

That was a pun in latin?
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Erasing drawn content

2010-06-09 Thread vincent habchi
Le 9 juin 2010 à 13:33, Alastair Houghton a écrit :

> On 9 Jun 2010, at 10:02, vincent habchi wrote:
>>> Pity, I like the idea of more bee-based metaphors in APIs (or Apis). It 
>>> could be known as Bee-OS.
>> 
>> That was a pun in latin?
> 
> <http://en.wikipedia.org/wiki/BeOS>
> 
> (which was once a candidate for the base of Mac OS X)

Yes, I know of Be-OS, and I have a NeXTStation somewhere a heap of old 
computers (an Oric 1, too, and various Atari ST/TT/Falcon).
But the point was that "apis", in latin, means "bee".

Cheers
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Erasing drawn content

2010-06-09 Thread vincent habchi
Le 9 juin 2010 à 13:44, Graham Cox a écrit :

> 
> On 09/06/2010, at 9:38 PM, vincent habchi wrote:
> 
>> But the point was that "apis", in latin, means "bee".
> 
> 
> I think we ought to buzz off and hive this off-list, or else we're likely to 
> get smoked out by the moderator. (Beesides, any joke that needs explaining 
> loses any small element of humour it might have had).

You're right. Let's say it was the five minutes Cocoa-U thread. :)
Vale atque salve ! :)
Vincent (going to lunch anyhow)___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


KVO oddity (or am I *really* idiot ?)

2010-06-09 Thread vincent habchi
Hi there,
no latin this time, I swear! :)

Well, please tell me I am a fool: when I execute those two lines:

NSLog(@"%@", [[NSApp delegate] appController]);
NSLog(@"%@", [NSApp valueForKey:@"delegate.appController"]);

I get this result:

2010-06-09 15:52:57.525 PostSIG[5503:a0b] 
2010-06-09 15:52:57.526 PostSIG[5503:a0b] [ 
valueForUndefinedKey:]: this class is not key value coding-compliant for the 
key delegate.appController.

[NSApp valueForKey:@"delegate"] works all right.
appController is a synthesized readonly property of the delegate.

What did I miss? 
Thanks (I cannot get rid of the impression that this question is silly)

___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: KVO oddity (or am I *really* idiot ?)

2010-06-09 Thread vincent habchi
Le 9 juin 2010 à 16:10, Graham Cox a écrit :

> 
> On 10/06/2010, at 12:05 AM, vincent habchi wrote:
> 
>> 2010-06-09 15:52:57.526 PostSIG[5503:a0b] [ 
>> valueForUndefinedKey:]: this class is not key value coding-compliant for the 
>> key delegate.appController.
>> 
>> [NSApp valueForKey:@"delegate"] works all right.
>> appController is a synthesized readonly property of the delegate.
>> 
>> What did I miss? 
> 
> 
> delegate.appController is not a key, it's a key PATH. Use it with 
> -valueForKeyPath:

Thanks to both. You see, I am *really* a moron (and sometimes even an oxymoron, 
which is worse! :)).___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: KVO oddity (or am I *really* idiot ?)

2010-06-09 Thread vincent habchi
Le 9 juin 2010 à 16:10, Kyle Sluder a écrit :

> @"delegate.appController" is a keypath, not a key.

Thanks Kyle. As I said (privately) to Graham, I am even better than a moron: an 
oxymoron.
Cheers and forgive my stupidity. Enjoy WWDC!

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSDictionaryController code example

2010-06-09 Thread vincent habchi
Hi again,

like some other before (pfiuh, I'm not alone this time!), I have some 
difficulties to fully grasp the way NSDictionaryController works (especially 
how to subclass -newObject to fit my needs). Does anybody, by chance, have a 
sample code that would demonstrate some basic use? I couldn't find any neither 
on the Apple doc nor on the web.

Thanks,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSOutlineView drag and drop problem

2010-06-11 Thread vincent habchi
Le 11 juin 2010 à 07:24, Graham Cox a écrit :

> The two methods do much the same work so there's a good opportunity to factor 
> the code as Jens suggests, but locally saving the return value from 
> validation works OK and appears to be all I can do.

Saving a return value in a ivar is usually not thread safe, but I guess this is 
not much a problem here…

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Double binding not possible?

2010-06-11 Thread vincent habchi
Hi there,
I hope this question will be less silly as the previous ones.
Yet, it is very simple: I have a popUp button with which I'd like to update two 
objects at the same time (one with the selected index, and the other with the 
selected value). Can you confirm me it is impossible (once one binding of the 
selected type is set, the other get greyed out).

Thanks
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Double binding not possible?

2010-06-11 Thread vincent habchi
Ken,

> Yes, it is impossible.

That's what I thought.

> Those bindings are two-way.  (Not all are, but those are.)  Thus, when the 
> bound-to property changes, so does the view's selection.  Now, how would this 
> work if the view's selection were bound to two different properties?  What if 
> those properties were inconsistent with each other?
> 
> Out of curiosity, which two objects were you binding to?  That may suggest a 
> design problem.  Or do you mean two properties of the same object?  Usually, 
> a view binding is bound to a property of a controller.

Roughly, I have two objects: one is a NSDictionaryController whose keys 
(NSStrings) are bound to the "Content Values" of the popUpButton. The "Selected 
Value" is bound to some attribute of a result object that collects the values 
chosen by the user (the PopUp button is part of a larger dialog). At the same 
time, I'd obviously like the "Selected Index" binding of the NSPopUp to be 
bound to the selectedIndex property of the NSDictionaryController, but that 
where it fails.

The easiest solution is to implement an IBAction, that's what I am doing 
currently.

Thanks a lot,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSArrayController/Modal dialog/KVO Gordian knot

2010-06-12 Thread vincent habchi
Hi again,

I am still stuck in my (very simple) dialog management. Briefly, I have a modal 
dialog that allows the user to create objects whose attributes are derived from 
various fields. I need to set the a default value to one attribute of a newly 
created object (after clicking on a button); however this scheme:

[arrayController insert]
[arrayController setSelectionIndex:0]
[[arrayController selection] setValue:foo forKey:@"spam"]

fails, because the creation of the new object is postponed until next Runloop 
iteration (so when the arrayController is void, there is no selection). I tried 
KVO on the "content" key of arrayController, but it fails also, the observation 
message seems to be hold until the modal runloop exits.

Any possible alternative?

Thanks,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSArrayController/Modal dialog/KVO Gordian knot

2010-06-12 Thread vincent habchi
Le 12 juin 2010 à 16:10, Keary Suska a écrit :

> Normally, default value logic should be within the model object, not the 
> controller. If the defaults are specific to the controller or situation (and 
> not to any other controller or situation), the controller should be told to 
> prepare its own content and set default values accordingly. Along with 
> setting "selects inserted objects", I consider one of these to be your best 
> alternative.

Well, I think the default value is within the model object. To make it clearer, 
suppose I have a model object (entity in Core data) that could represent fruits 
(in general) and has a "color" attribute. I have a PopUp that allows the user 
to select exactly what fruit he wants to create (apple, cherry, lemon…) and 
when it clicks on the "new" button (or changes his mind after), the "color" 
attribute of the newly created object is set accordingly.

The mechanism I use is this: I register key/value pairs in a dictionary 
(@"apple"/apple_object, @"cherry"/cherry_object…), controlled by a 
NSDictionaryController; The keys are displayed as PopUp value items, and each 
fruit object abides by a protocol featuring a + (NSString)color method that 
returns the appropriate color. The color field should be set to : 
theDictionary.selection.value.color; but I can't get a valid "selection" proxy 
object. I tried to use a non-modal window, but to no avail. There seems to be 
an interference with core data.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSArrayController/Modal dialog/KVO Gordian knot

2010-06-13 Thread vincent habchi
Hallo Reinhard,

Le 13 juin 2010 à 09:36, Reinhard Segeler a écrit :

> I am not familiar with the NSDictionaryController but the keypath looks a bit 
> strange:
> 
> if theDictionary is what the name says, then a member selection calls a 
> member value calls a member color. That's not the case, isn't it?

theDictionary has a selection made of key/value couples ; each couple is a 
KVO-compliant object for the keys "key" and "value" and the value is a class 
object which features a + (NSString *)color method. Believe me, it works all 
right.

> In my code I bind a popupMenu by using the following path: self.dict.index to 
> select a menu item by index. - no Controller is used here.
> 
> I looked in my literature where I found the following:
> 
> Bind to: aDictController
> Controller key: selection
> Model key path: name -> in your case color?

In your case, you forget a step (choose between "key" and "value" attributes).

Actually, I found a solution to my problem. Instead of observing the "contents" 
property of the array to catch changes in the dictionary, I observe "selection" 
and that works. It does not explain why the "contents" observation does not 
trigger messaging while the dialog is active, albeit I insert an object in the 
array.

Tchüß,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Core Data issue .. where is my bug?

2010-06-13 Thread vincent habchi
Le 14 juin 2010 à 07:32, Robert Lorentz a écrit :

> Now - this is where my issue starts - if I instead bind my NSTextField to 
> "array controller - selection.description", my program crashes with EXC BAD 
> ACCESS!  I have edited the store file, and confirmed that yes I do have 
> attribute entries for "name" and "description" both.  

Description is a kind of reserved name: it is normally bound in every object 
(since it is defined in the NSObject root class) to a method giving the result 
of "print operation" like NSLog(@"%@", object). Try to use another name 
instead, like "descr", for example.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSRunLoop

2010-06-14 Thread vincent habchi
Le 15 juin 2010 à 00:41, Jean-Daniel Dupas a écrit :

> 
> Le 15 juin 2010 à 00:22, Ariel Feinerman a écrit :
> 
>> Hi,
>> I wish to make programme has cpu-related (one thread per core) number of
>> worker threads. When user inputs the data, main thread splits up the data
>> and send to the workers. Then worker threads go to sleep in anticipation of
>> the next chunk of data. How can I do it? I think to NSRunLoop is the best
>> way, is the example of code?
>> 
> 
> I guess that if you ask this, you need to deploy on Mac OS 10.5 or older, 
> else instead of bothering with your own thread pool, just use GCD.
> If you want to do that for 10.5, use NSOperationQueue.

You can also use mutexes (NSLock) or semaphores to synchronise your code; 
typically, the systems puts to sleep any thread that is waiting for a lock, so 
it does not waste CPU power. Your main thread acquires lock, write buffers, and 
when it's time it releases the lock that the auxiliary thread acquire, consume 
the data, then release the lock and so on.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Notification when network volume disappears

2010-06-14 Thread vincent habchi
Le 14 juin 2010 à 20:37, Jens Alfke a écrit :

> Last I heard (admittedly, a few years ago) there wasn’t any good way to do 
> async/nonblocking filesystem operations. The standard system calls block; the 
> O_NONBLOCK mode for fcntl only works on network socket streams; and the AIO 
> API has (had?) significant issues.

You can try also to set a background thread that sends periodic pings (ICMP 
packets) to the IP you are writing to, e.g. every second. If you register more 
than 5 errors in a raw, then you can (maybe) assume your link is down. That's 
how ping(1) works.

You would maybe have to adjust your timeout depending on the number of hops 
(you can get it in the returned ICMP echo): whereas in a local network it is 
safe to assume than a five second interruption means a breakdown somewhere, if 
you're writing over the Internet, this is obviously wrong.

As for the removal of the cable on the local machine, there must be some way 
Cocoa is informed (utilities exists at the BSD level).

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSTextField selection customization

2010-06-15 Thread vincent habchi
Hi there,

I'd like to customize the way an NSTextField works, especially the selection 
mechanism (I'd would like the selection to break only at word boundaries, 
instead of at every character). Is this possible, or shall I turn to the bigger 
and bulkier NSTextView?

Thanks,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTextField selection customization

2010-06-15 Thread vincent habchi
Le 15 juin 2010 à 21:58, Jens Alfke a écrit :

> You’ll end up working with NSTextView regardless. NSTextField doesn’t do its 
> own text editing, it overlays a text view called the ‘field editor’ that’s 
> used by all controls in the window. So to make this work in a text field 
> you’d need to create a tricked-out text view and then install it as a custom 
> field editor on that text field.

Thanks for the answer, that's what I suspected. Before getting on, what, in 
your opinion, is the most handy solution? In order, what would you advise : 
NSTextView or a custom field editor?

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTextField selection customization

2010-06-15 Thread vincent habchi
Jens, Graham,

> Note that NSTextView has: - 
> (void)setSelectionGranularity:(NSSelectionGranularity)granularity

Yes, I saw that, it's a nice method.

> which might be all you need - just set it to NSSelectByWord every time you 
> change the selection. This will keep getting reset so something will need to 
> keep forcing it back to 'word' selection, but it might be possible to do this 
> in the delegate and not require a subclass.

Actually, I need a mix of both modes (I need to rub out keywords on a per-word 
basis, but let variables be corrected on a character granularity); so I won't 
be trivial, but far to be impossible.

Thanks to both,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Memory management on returning nil in init

2010-06-21 Thread vincent habchi

Le 21 juin 2010 à 16:43, Eiko Bleicher a écrit :

> One of my initializers can fail and thus it should return nil. Consider the 
> following example:
> 
> -(id) initWithBool:(BOOL)ok
> {
>   if (self = [super init])
>   {
>  if (!ok) {
> return nil; // Point of interest
>  }
>   }
>   return self;
> }
> 
> Does this code leak? I am inclined to think I need to call [self release] 
> before returning nil, but I am yet to see a piece of example code for this. 
> Or is my approach stupid? :-)

What the point of the OK variable ?

You can call [self release] safely, since if self is nil, the message is just 
silently discarded. That's what I usually do.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Smooth OpenGL animation possible, even if main thread blocks?

2010-06-25 Thread vincent habchi
> So what are we supposed to do? Is there something I'm overlooking here or 
> should we maybe stop using CALayers and instead use NSOpenGLView or maybe 
> even manage our own OpenGL Context, render into a background buffer (e.g. 
> some kind of image) and then directly paint this image from within the 
> background thread into the view whenever we want to? If so, what image is 
> most effective for such a task? NSImage, CGImage, CIImage? Any advise is 
> highly appreciated.


As far as my experience goes, it was perfectly possible to update a CALayer 
from a background thread as long as you make this thread run its own runloop. 
That's what I did some time ago before reverting to the classical method for 
the sake of complexity.

No guarantee though, I'd rather let the specialists speak.

Cheers!
Vincent
Sent from my iPhone4 ;)

___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Toolbar Icon Workflow

2010-06-27 Thread vincent habchi
Le 27 juin 2010 à 12:42, Graham Cox  a écrit :

> It shouldn't, as it has no native resolution. What can happen though is that 
> NSImage caches it to a bitmap and reuses the bitmap, which can become fuzzy 
> when scaled up. You could investigate turning off caching on the image to 
> avoid that.
> 
AFAIK, there might be also some issues when scaling down, e.g. if you scale 
down a checker board, it might end up being monochrome. Sometimes, you'll want 
to design two different icons, the smaller one leaving out some details that 
would otherwise confuse the image.

Vincent


___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Smooth OpenGL animation possible, even if main thread blocks?

2010-06-28 Thread vincent habchi
Markus,
> "Possible" or "Allowed"? ;-)

Both, I think. If I am not mistaken, it was some Apple guy (David Duncan?) who 
pointed out the role of the runloop. I therefore take for granted that, if it 
is not "allowed", it must at least be "tolerated".

> It is also possible to use Cocoa UI objects from different threads; at least 
> if you do it carefully, you might get away with that. However, I doubt this 
> is really allowed and if it stops working, Apple will say "We told you not 
> to...".  Considering that the future of processing is more and more cores 
> (virtual or physical ones), it is pretty unfortunate that Cocoa is so little 
> thread-safe and that UI is still often bound to main thread.

I think Apple is well aware of that. I'd bet this is one of their priorities 
for MacOS 10.7... Just a wild guess, though.

Vincent

Sent from my iPhone4


___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Smooth OpenGL animation possible, even if main thread blocks?

2010-06-28 Thread vincent habchi
Le 28 juin 2010 à 15:01, Markus Hanauska a écrit :

> What does work, but I doubt it is allowed, is to directly call 'display' on 
> the CALayer. Apple says "you should not call this method directly", but so 
> far it seems to work and has not crashed... on the other hand it might crash 
> if the CALayer is destroyed on the main thread asynchronously (that can be 
> avoided, though, by making sure the other thread stops first, before the 
> CALayer is ever destroyed). Another issue is that it might cause refreshes of 
> the CALayer, even thought the layer is not even visible right now (e.g. the 
> whole Window is minimized); but that could be solvable, too, though I'm not 
> sure how (querying UI properties of elements from a thread other than main is 
> definitely not thread-safe).

I never called -display directly. I think the benefit of having a runloop is 
precisely to avoid this call. When I wanted to remove one CALayer, I stopped 
the Runloop (by calling a suitable method), the thread then quit after removing 
its CALayer (in my case, I was refreshing in parallel a lot of CALayers grouped 
in a CAScrollLayer, and, to keep a reasonable number of threads, I destroyed 
the layers that weren't visible by a certain margin).

As for the second issue, you can implement a test in the -drawLayer:inContext 
delegate method, no?

Jedoch, viel Spaß ;)
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How tell tell if an NSNumber was initialized from a float or int?

2010-06-28 Thread vincent habchi
Le 28 juin 2010 à 15:19, Kyle Sluder a écrit :

> Tell you what, I'm gonna stop posting to the list within the 10
> minutes after I first wake up. Then maybe I wouldn't have overlooked

Allow yourself at least the time to get a deep intravenous injection of dark 
coffee! :)
Vincent



___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Bypass Network System Preferences for DNS lookup

2010-07-02 Thread vincent habchi
Afaik, no. Why would you do that?

Sent from my iPhone4


___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSTextField fieldeditor subclass example? (and an unrelated other inquiry)

2010-07-06 Thread vincent habchi
Hi there,

after a small interruption, I am about to resume Cocoa coding with what seems 
to me one of the hardest things I ever made so far with the Mac: coding a SQL 
custom editor with token handling (keyword and column name coloring, 
completion, automatic selection extension on keyword boundaries).

Before I dive into it, has somebody ever stumbled on example code that would 
cover part of what I try to do?

Thanks a lot,
Vincent

BTW, another unrelated question. I have a method that takes an NSPoint as an 
argument. I call it this way:

[foo point:NSMakePoint(x, y)]

and get an analyzer warning: "Pass-by-value argument in function call is 
undefined".

Should I recode the function so that it takes a NSPoint * instead?

___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTextField fieldeditor subclass example? (and an unrelated other inquiry)

2010-07-06 Thread vincent habchi
Le 6 juil. 2010 à 21:59, Matt Neuburg a écrit :

> On Tue, 6 Jul 2010 20:31:06 +0200, vincent habchi  said:
>> BTW, another unrelated question. I have a method that takes an NSPoint as an
> argument. I call it this way:
>> 
>> [foo point:NSMakePoint(x, y)]
>> 
>> and get an analyzer warning: "Pass-by-value argument in function call is
> undefined".
> 
> How about passing an NSValue? Surely valueWithPoint: must be good for
> something... :) m.

Geez, I just realize I have been browsing the NSValue page for iPhone OS since 
the beginning, and iPhone OS (iOS) has no +valueWithPoint. I feel Apple should 
one way or an other (e.g. by changing the background) catch the attention of 
the reader about the OS that the current documentation page applies to (is that 
correct English? I wonder).

So, okay, but why should I incur the penalty of creating an object while 
passing a structure (even by value) is perfectly valid since K&R C? I don't 
understand the meaning of the warning.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to debug crash on startup of 64-bit build

2010-07-06 Thread vincent habchi
Le 6 juil. 2010 à 22:49, Jeffrey J. Early a écrit :

> Importantly, I'm not calling any code framework A that depends on framework 
> B. Because of this, in 32-bit mode, it ended up being totally okay that 
> framework B was missing (presumably because it never had to resolve any 
> symbols from that framework.) However, in 64-bit mode, it produced the crash 
> at launch time that I pasted in the previous email.

Try to have a look on the ld(1) man page, and especially weak-imports, that is 
symbols that are allowed to miss at runtime without error.

V.

___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


How to properly print a SEL type variable?

2010-07-06 Thread vincent habchi
Hi there,
this is a very simple question, but I don't seem to find the answer anywhere.

What is the proper format to use in NSLog to print out a SEL type variable? E.g.

SEL aSelector = @selector (foo);
NSLog ("%", foo);

If I use %s, it works, but I get a warning because the variable is not of the 
char* type.

Thanks!
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to properly print a SEL type variable?

2010-07-06 Thread vincent habchi
Le 7 juil. 2010 à 07:10, Stephen J. Butler a écrit :

> NSStringFromSelector() and then use %@ in the format string.

Thanks! Well, I guessed there had to be such a function, but I don't know why 
they are not at least referenced in the NSString class doc page. I know there 
are not part of the NSString API stricto sensu (or lato sensu), but the doc 
page should at least reference them in a way or another.

Vincent

___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Pass-by value… warning (was: NSTextField fieldeditor subclass example? (and an unrelated othe r inquiry))

2010-07-06 Thread vincent habchi
Hi!

Le 6 juil. 2010 à 21:59, Matt Neuburg a écrit :

> On Tue, 6 Jul 2010 20:31:06 +0200, vincent habchi  said:
>> BTW, another unrelated question. I have a method that takes an NSPoint as an
> argument. I call it this way:
>> 
>> [foo point:NSMakePoint(x, y)]
>> 
>> and get an analyzer warning: "Pass-by-value argument in function call is
> undefined".
> 
> How about passing an NSValue? Surely valueWithPoint: must be good for
> something... :) m.

It appears the warning should be read: "The variable you pass to NSMakePoint is 
undefined". The real code looks like this: 

- (void)drawPoint:(CGContextRef)ctx origin:(CGPoint)origin dimension:(int)dim 
data:(char **)data {
double pt [dim];

for (int i = 0 ; i < dim ; i ++) {
memcpy (& (pt [i]), * data, sizeof (double));
* data += sizeof (double);
}

NSPoint point = [displayController mapToLayerCoordinates:NSMakePoint(pt 
[0], pt [1])];

The analyzer does not figure out that the pt array gets initialized through the 
loop by copying values directly from a chunk of memory, and spits out the 
warning about pt [•] not being defined. Maybe I should report this to the LLVM 
team?

Vincent

PS : Note that the (char **) may seem a bit clumsy, but the chunk of memory 
contains different informations, not only double. I will probably rewrite it 
thus:

- (void)drawPoint:(CGContextRef)ctx origin:(CGPoint)origin dimension:(int)dim 
data:(double **)data {
double pt [dim];

for (int i = 0 ; i < dim ; i ++, *data ++) {
memcpy (& (pt [i]), * data, sizeof (double));
}
___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Pass-by value… warning

2010-07-07 Thread vincent habchi
Le 7 juil. 2010 à 08:54, Greg Guerin a écrit :

> vincent habchi wrote:
> 
>> The analyzer does not figure out that the pt array gets initialized through 
>> the loop by copying values directly from a chunk of memory, and spits out 
>> the warning about pt [•] not being defined. Maybe I should report this to 
>> the LLVM team?
> 
> 
> That seems like a good idea.
> 
> However, also consider that 'dim' may take on values 0 or 1.  If dim is 0 or 
> 1, then the local 'pt' array may not have valid elements at pt[0] or pt[1].  
> You may know that dim is never 0 or 1, but the analyzer has no way of knowing 
> that.
> 
> And I don't know what might happen if dim is negative.

That's true, the compiler cannot guarantee that dim > 1, which is always the 
case actually.
I am going to put an extra text at the beginning of the method, like: "if (dim 
< 1) return;" and see what happens.

Vincent

___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Pass-by value… warning

2010-07-07 Thread vincent habchi
Le 7 juil. 2010 à 09:23, vincent habchi a écrit :

> That's true, the compiler cannot guarantee that dim > 1, which is always the 
> case actually.
> I am going to put an extra text at the beginning of the method, like: "if 
> (dim < 1) return;" and see what happens.

The warning goes away when I do that. Nice! Finally, I think it's not a bug, 
but rather a great feature. I am surprised by the degree of wisdom the LLVM 
team put into this analyzer. It's really a great tool.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Pass-by value… warning (was: NSText Field fieldeditor subclass example? (and an unrelate d other inquiry))

2010-07-07 Thread vincent habchi
Le 7 juil. 2010 à 09:33, Graham Cox a écrit :

> 
> On 07/07/2010, at 3:59 PM, vincent habchi wrote:
> 
>> - (void)drawPoint:(CGContextRef)ctx origin:(CGPoint)origin 
>> dimension:(int)dim data:(double **)data {
>>  double pt [dim];
>>  
>>  for (int i = 0 ; i < dim ; i ++, *data ++) {
>>  memcpy (& (pt [i]), * data, sizeof (double));
>>  }
> 
> 
> I have to ask - why are you doing a copy here, and in such an inefficient way 
> too? Your data already is an array of doubles, why do you need to convert to 
> another one? Also, why the double indirection?

The double indirection is necessary in order for the master data pointer 
(*data) to progress through the data chunk; since that chunk can hold different 
items, I have to decode it on the fly and call the appropriate method that 
interprets an appropriate block of data. If I were using a '(double *)data' 
instead, I would end up incrementing a local copy, and the main pointer in the 
caller method would not be altered. Or am I mistaken?

But, basically you're right about the copy. This might be more canonical:

[foo point:NSMakePoint (* data, * (data + 1))];
* data += dim;

Thanks for pointing me out this, as always, your comments are *really* helpful

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Scrolling not working ...

2010-07-07 Thread vincent habchi
Le 7 juil. 2010 à 08:42, Jay Reynolds Freeman a écrit :

> I have has reasonable values.  The actual code is based on the
> example for program-controlled scrolling in the documentation, and
> goes like this:
> 
>  NSPoint scrollerOrigin = [[ contentView] bounds].origin;
> 
> Then, later:
> 
>  [[ documentView] scrollPoint:scrollerOrigin];
> 
> And no scrolling takes place.

Did you try:
[[ documentView] scrollPoint:NSMakePoint(0, 0)]; ?

Vincent

___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: static analyzer

2010-07-07 Thread vincent habchi
Le 7 juil. 2010 à 20:35, Bill Bumgarner a écrit :

>> Is that generally true? I mean, first of all, false positives are a
>> well-known phenomenon with this static analyzer (the Web page at llvm.org
>> talks about this). Second, they do no harm. I get a false positive in *any*
>> of my apps that uses NSURLConnection, for example:
> 
> Yup.  That is really true.  False positives are taken very seriously.

At the end, as I wrote, it turns out it was not really a false positive, but 
the message was somewhat unclear (sibylline, is that English?). The warning has 
gone away when I put the test before, so I assume this is normal and desired 
behavior. However it does raise the question to know if the static analyzer can 
figure out twisted initialization with functions such as memcpy. 

The response as far I can fathom it out of a few simple tests is yes in most 
cases but sometimes no.

The following code:

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int foo;
int fee;

// insert code here...
NSLog(@"Hello, World!");
// memcpy (& fee, & foo, sizeof (foo));
Logit (fee);

[pool drain];
return 0;
}

correctly produces a warning about 'foo' not be used and the famous message 
"Pass-by-value argument in function call is undefined" that should best be 
written as "passED-by-value argument in function call is undefined" (as far as 
my understanding of the English grammar goes).

Now, this code: 

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int foo;
int fee;

// insert code here...
NSLog(@"Hello, World!");
fee = foo;
// memcpy (& fee, & foo, sizeof (foo));
Logit (fee);

[pool drain];
return 0;
}

itches the analyzer with an "Assigned value is garbage or undefined" message on 
the line fee = foo, which is nice. Was it right to cancel the warning about the 
undefined parameter? That's questionable but admissible.

Now this version :

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int foo;
int fee;

// insert code here...
NSLog(@"Hello, World!");
memcpy (& fee, & foo, sizeof (foo));
Logit (fee);

[pool drain];
return 0;
}

does not make the static analyzer protest, so I assume its default behavior is 
to assume that any variable used as a destination of memcpy is initialized, 
regardless of the source. But, IMO, we have already encroached on a semantic 
realm beyond the reach of any decent general purpose code analyzer.

Vincent (with my excuses to the moderator for being also borderline as to the 
contents. I swear I will post further responses off 
list).___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Sanity Check

2010-07-08 Thread vincent habchi
Le 8 juil. 2010 à 19:34, Kyle Sluder a écrit :

>> Because I retain it in the init method , I don't need a reference to it
>> where the alloc is called
> 
> Retaining self in -init is wrong. It doesn't matter if it works.

You can retain your controller in -windowDidLoad and (auto)release it in 
-windowWillClose. That's what I usually do for non-modal windows. For modal 
window, the problem is even more simple.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Programmatically highlighting an NSMenuItem

2010-07-08 Thread vincent habchi
Le 8 juil. 2010 à 18:57, augusto callejas a écrit :

> yes i know its not a real menu, but given it mostly behaves like one,
> i was trying to use existing functionality without having to rewrite the 
> menu-ing system.

As far as I know, you cannot use menu to do what you seek to achieve. You would 
lose focus on the NSTextField you use to type and that would be strange.

Don't forget to set the backgroundColor of your custom NSView to clearColor and 
setOpaque to no.

Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: setting focus on NSSearchField in status bar menu item

2010-07-08 Thread vincent habchi
Le 8 juil. 2010 à 21:26, Nava Carmon a écrit :

> Can somebody answer this please?
> 
>> I added a custom view with a NSSearchField as a first menu item to a status 
>> bar menu. When I run the application from debugger I can click and write in 
>> the NSSearchField. After I go to another application, make it front and 
>> click again on my status menu, the NSSearchField shows, but it's disabled 
>> and can't get focus. The question is how to cause the NSSearchField to get 
>> focus each time, the user clicks to show the menu?

I cannot precisely figure out what you've tried to do, but, as I said in 
another thread, popping up a menu will make lose focus to any other view, so I 
am unsure you can add a text editing view to it.

Vincent

___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Use of blocks

2010-07-12 Thread vincent habchi
Buongiorno :)

Le 12 juil. 2010 à 09:34, Giannandrea Castaldi a écrit :

> I want to use blocks to extract the min price and the max price from
> an NSArray of trips. I've found the following way:
> 
>float minValue = 0.0;
>[someTrips enumerateObjectsUsingBlock:^(id obj, NSUInteger idx,
> BOOL *stop) {
>  if (minValue == 0.0 || [[obj adultFinalPrice] floatValue] < minValue) {
>minValue = [obj floatValue];
>  }
>}];

[…]

Did you test it? Does it work? I've always heard that you could not modify 
block external variables unless you prefix them with __block. Otherwise the 
variable is just a const reference. 

Buon proseguimento,
Vincent

___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Animate NSWindow frame using Core Animation?

2010-07-16 Thread vincent habchi
Le 16 juil. 2010 à 12:38, Oleg Krupnov a écrit :

> Any other ideas?

Is your view CALayer backed?
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Initializing unichar variable with a human readable letter

2010-07-17 Thread vincent habchi
Hi there,

I have a very simple problem: I'd like to affect to a unichar variable the 
value of the glyph é (or any non-ascii character).

If I (naively) write: "unichar foo = 'é';", I get a warning from the compiler 
about multibyte const and it does not work.

I'd like to avoid twisted constructs like [@"é" characterAtIndex:0], which 
works but looks weird, or esoteric notations like '\u' at whose reading 
nobody can figure out what the char is.

Does anybody knows about a better solution?

Thanks a lot and have a nice week-end
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Initializing unichar variable with a human readable letter

2010-07-18 Thread vincent habchi
Hi Ken,

> Doing this will probably work:
> unichar foo = L'é';

Thanks, that's perfect.

> With modern compilers, it should be possible to do (roughly) what you want if 
> the source file is UTF-8 encoded.  However, note that "é" is often 
> represented as "e" followed by U+0301 COMBINING ACUTE ACCENT.  That is, the 
> single grapheme is two characters.  So, no matter the encoding, that won't 
> fit into a unichar.  There is a single precomposed "é" character, U+00E9 
> LATIN SMALL LETTER E WITH ACUTE, but it's not always clear which you get with 
> any given input mechanism.

It seems Xcode represents the 'é' with the unicode char and not the 
combination, so that's fine for me. Besides, to answer your question, I use the 
latest clang/llvm pair out of MacPorts (I found somewhere on a site the proper 
file to hack to make Xcode work with these rather than the Apple provided 
clang/llvm which are always a bit out of phase).

Since I use the unichar to make comparisons, I could also have initialized a 
custom NSCharacterSet with "é", but, as we say here in France: "it's like using 
a bulldozer to break a nut shell".

Thanks again, enjoy your Sunday
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Small caps in NSTextView

2010-07-22 Thread Vincent Habchi
Hi!

I'd like to highlight some text in a NSTextView by showing it in small caps. It 
seems this is not a standard text attribute, so this is not possible unless 
changing [NSTextView string] contents. Is this right?

Thanks!
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Small caps in NSTextView

2010-07-22 Thread vincent habchi
Ross,

thanks a lot for your hints.

> Small caps is not a trivial thing to implement, especially if you care about 
> how they look.

Not too much. I just want to dynamically highlight keywords in a SQL sentence 
(e.g. out of "select * from" -> "SELECT * FROM"). My present solution is to get 
the NSTextView string in the -(void)textDidChange: method of the delegate, then 
analyze the string. If I recognize a keyword, I replace it in the text by a 
[NSString uppercaseString] version with 
-(void)replaceCharactersInRange:WithString:

> Regarding modifying the text storage contents: the problem is not so much 
> with changing text to small caps, but rather with changing it back. If you 
> modify the  string to change Apple to APPLE, then you cannot know whether 
> APPLE should be changed back to Apple or apple. This problem can be solved by 
> subclassing NSGlyphGenerator to return an uppercase character if a custom 
> SmallCaps attribute is present in the attributed string.

That's the problem. I tried to solve it by storing the original version and 
reverting to it if necessary, but it works only in the "current" token ("selec" 
-> "SELECT" -> "selecti" -> "SELECT" -> "selec"), and cannot be applied to 
already fully processed keywords. That's why I was looking to attributes, that 
do not modify text, and can be easily reverted.

I share your opinion about Small Caps, they look beautiful when properly 
printed. I used them from time to time in the settings of some articles of the 
magazine I am in care of, it's gorgeous, but in small amounts.

Cheers and thanks again,
Vincent___

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-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


  1   2   3   4   >