Re: Proper NSOperation isCancelled handling

2009-02-13 Thread Ken Thomases

On Feb 12, 2009, at 1:29 PM, Alex Curylo wrote:

So I'm a bit confused about how my NSOperation subclass should  
implement the cancel method.


Why are you overriding it?  The -cancel method is not supposed to  
actively bring the operation to a stop.  It's only supposed to set a  
flag.  The operation's work methods (-start, -main, and whatever they  
call) should be periodically checking the -isCancelled property and,  
if it's set, gracefully bring their work to an end.


Regards,
Ken

___

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: Garbage Collection and NSManagedObject

2009-02-13 Thread Samuel Strupp
You are right i forgot to remove the persistant store from the  
coordinator. But i am not sure if that is important because i set the  
context and coordinator refs to nil.


managedObjectContext = nil;
persistentStoreCoordinator = nil;
managedObjectModel = nil;

After this I thought the garbage collector is deleting all these  
objects. Even if I remove the store from the coordinator before, I  
have the same problem of INVALIDATED objects. Because this problem  
occurs only sometimes (10% percent of manually started reconnects), I  
thought this is a garbage collector problem.


My main question is: Is there a way to wait until the garbage  
collector is finished with a "collectExhaustively"?


thanks for the help
Samuel




Am 12.02.2009 um 17:23 schrieb I. Savant:

On Thu, Feb 12, 2009 at 10:55 AM, Samuel Strupp   
wrote:


I simply want to delete the actual database (SQL Database) and load  
a new

one.


 Okay.

First: all controllers which hold refs to NSManagedObjects will be  
deleted.


 What do you mean "deleted"? Do you just mean you're disconnecting
them from their managed object context?

Then the i call [[NSGarbageCollector defaultCollector]  
collectExhaustively];


 Why? If you're going to do it at all, I'd imagine you'd do it after
the tear-down of *everything* related to your context and persistent
store.


Then i disconnect from the database.


 Again, I'd do this *before* forcing collection.


This is the code to disconnect from the databse:

-(BOOL) removeData {
NSError *error;
if (managedObjectContext != nil) {
   if ([managedObjectContext commitEditing]) {
if ([managedObjectContext persistentStoreCoordinator]
&&
[[[managedObjectContext persistentStoreCoordinator]  
persistentStores] count]

0) {

if ([managedObjectContext hasChanges] &&
![managedObjectContext save:&error]) {
NSLog(@"Save Error.");
}
}
}
}
managedObjectContext = nil;
persistentStoreCoordinator = nil;
managedObjectModel = nil;
return YES;
}



 I don't see any code related to removing the context and
disconnecting from the persistent store. Are you really pulling the
store's file (the sqlite database) out from underneath Core Data and
expecting it to work normally? I wouldn't.


The problem is that the disconnect and the collection of garbage is
parallel. So the invalidate exception is thrown.


 Are you *sure* that's the problem? It may not be. My first suspect
is that I don't see anywhere that you're actually tearing down the
right parts of the Core Data stack (the context and the persistent
store).

I have no problems with the disconnect from the old and the  
reconnect to new

databse. Thats working. Only the old NSManagedObjects seems to be not
deleted and create errors.


 Well, no, it's not really working, is it? The managed objects should
go away with your context. If they're sticking around and throwing
errors, that's your first clue that you're likely not handling the
Core Data stack properly during this disconnect process.

 Core Data lets you create and remove as many contexts as you like to
a persistent store - this is one of the features that makes Core Data
shine (and even gives it the ability to handle multithreading with
grace). If you've got managed objects hanging around after you dispose
of a context, you're "doing it wrong":

Core Data Programming Guide
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CoreData/cdProgrammingGuide.html

Low Level Core Data Tutorial
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CoreDataUtilityTutorial/Articles/chapter_1_section_1.html

--
I.S.


Samuel Strupp

Synium Software GmbH
Robert-Koch-Str. 50
55129 Mainz

Internet: www.synium.de
E-Mail: str...@synium.de
Telefon: +49 (0)6131 4970 217
Telefax: +49 (0)6131 4970 12
Handelsregister: Amtsgericht Mainz, HRB 40072
Geschäftsführer: Robert Fujara, Mendel Kucharzeck

___

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


isNotEqualToString

2009-02-13 Thread Chunk 1978
i'm trying to minimize my if statement.  i have the following which works:

-=-=-=-
if (([currentDesktopBackgroundImage isEqualToString:firstPath]) ||
([currentDesktopBackgroundImage isEqualToString:secondPath]))
{
//Go North
}
else
{
//Go South
}
-=-=-=-

i'd like to remove the else part but the following doesn't work:

-=-=-=-
if ((![currentDesktopBackgroundImage isEqualToString:firstPath]) ||
(![currentDesktopBackgroundImage isEqualToString:secondPath]))
{
//Go South
}
-=-=-=-

wtf?
___

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: isNotEqualToString

2009-02-13 Thread matt . gough


On 13 Feb 2009, at 10:00, Chunk 1978 wrote:


-=-=-=-
if ((![currentDesktopBackgroundImage isEqualToString:firstPath]) ||
(![currentDesktopBackgroundImage isEqualToString:secondPath]))
{
//Go South
}


lets assume that currentDesktopBackgroundImage IS firstPath (and that  
secondPath ≠ firstPath)


The first portion of your test gives false so it tries the second  
portion.

This gives true, since currentDesktopBackgroundImage ≠ secondPath

so you go south. Your version will always Go South UNLESS  
currentDesktopBackgroundImage == firstPath == secondPath


I think you want this;

if (!([currentDesktopBackgroundImage isEqualToString:firstPath] ||
[currentDesktopBackgroundImage isEqualToString:secondPath]))
{
//Go South
}

Matt___

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: isNotEqualToString

2009-02-13 Thread Alexander Spohr

Ahem,

if you invert part, you’ll invert all...

|| should become &&

atze


Am 13.02.2009 um 10:00 schrieb Chunk 1978:

i'm trying to minimize my if statement.  i have the following which  
works:


-=-=-=-
if (([currentDesktopBackgroundImage isEqualToString:firstPath]) ||
([currentDesktopBackgroundImage isEqualToString:secondPath]))
{
//Go North
}
else
{
//Go South
}
-=-=-=-

i'd like to remove the else part but the following doesn't work:

-=-=-=-
if ((![currentDesktopBackgroundImage isEqualToString:firstPath]) ||
(![currentDesktopBackgroundImage isEqualToString:secondPath]))
{
//Go South
}
-=-=-=-

wtf?
___

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/atze%40freeport.de

This email sent to a...@freeport.de


---
Alexander Spohr
Freeport & Soliversum

Fax: +49 40 303 757 99
Web: http://www.freeport.de/
Box: http://dropbox.letsfile.com/02145299-4347-4671-aab9-1d3004eac51d
---



___

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: isNotEqualToString

2009-02-13 Thread Stephen J. Butler
On Fri, Feb 13, 2009 at 3:00 AM, Chunk 1978  wrote:
> i'm trying to minimize my if statement.  i have the following which works:
>
> -=-=-=-
>if (([currentDesktopBackgroundImage isEqualToString:firstPath]) ||
> ([currentDesktopBackgroundImage isEqualToString:secondPath]))
>
> i'd like to remove the else part but the following doesn't work:
>
> -=-=-=-
>if ((![currentDesktopBackgroundImage isEqualToString:firstPath]) ||
> (![currentDesktopBackgroundImage isEqualToString:secondPath]))

De Morgan's Law: http://en.wikipedia.org/wiki/De_Morgan%27s_laws

To wit: when negating, that || becomes an &&
___

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: isNotEqualToString

2009-02-13 Thread Sherm Pendley

On Feb 13, 2009, at 4:00 AM, Chunk 1978 wrote:

i'm trying to minimize my if statement.  i have the following which  
works:


-=-=-=-
if (([currentDesktopBackgroundImage isEqualToString:firstPath]) ||
([currentDesktopBackgroundImage isEqualToString:secondPath]))
{
//Go North
}
else
{
//Go South
}
-=-=-=-

i'd like to remove the else part but the following doesn't work:

-=-=-=-
if ((![currentDesktopBackgroundImage isEqualToString:firstPath]) ||
(![currentDesktopBackgroundImage isEqualToString:secondPath]))
{
//Go South
}
-=-=-=-

wtf?


Your two statements are not equivalent. In your first version, you go  
north if either comparison is true, and south only if *both*  
comparisons are false. In the second, you go south if *either*  
comparison is false.


For the second statement to be equivalent to the first, it needs to  
use && instead of ||.


sherm--

___

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


System Preferences "halo/spotlight" effect

2009-02-13 Thread John C. Daub

Hello.

In Leopard's System Preferences application, when you type into the search
field in the toolbar it presents a list of helpful keywords. In addition,
the content area of the window dims and a halo/spotlight effect appears over
each icon that is a possible match for what's being typed.

I'm trying to replicate that overlay halo/spotlight behavior, in a similar
sort of window (window full of icons). I'm seeking guidance in how to
achieve this.


I'm figuring in System Preferences it's using an overlay window, but since
my content scrolls I cannot use a window and must use an NSView. I did find
-[NSView addSubview:positioned:relativeTo:], which helped me position my
"halo view" atop my contents, and I have been fiddling around with various
things trying to accomplish the effect but I can't quite get there. I do see
within System Preferences.app/Contents/Resources/ a spotlight.tif and
spotlightdim.tif which provide the halo masking, and I experimenting with
rendering copies of those TIFF's via
-drawAtPoint:fromRect:operation:fraction: within my -[HaloView drawRect:]
and I could sorta get things to work with a fraction of 0.5. But that just
gives me the halo. I'm struggling to get the fill over the full content
area, that then doesn't affect the halo areas.

So I'm just looking for pointers on how to accomplish this. Am I just
overlooking the right combination of fills, strokes, alpha, NSBezierPath's,
and compositing? Do I need to look at OpenGL (never used it before)? Core
Image? Would things like -[NSView contentFilters] help me here? Never used
them before, tho I'm reading documentation. Some other approach entirely? In
all my years of programming I've never had to do a graphical effect like
this so I'm a little lost as to the direction to go.

Thank you for your assistance.

-- 
John C. Daub }:-)>=
 
"You can believe you can, or you can believe you can't; either way you will
be correct." -- Henry Ford.



___

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: Proper NSOperation isCancelled handling

2009-02-13 Thread Alex Curylo


On 13-Feb-09, at 12:31 AM, Ken Thomases wrote:

Why are you overriding it?  The -cancel method is not supposed to  
actively bring the operation to a stop.  It's only supposed to set a  
flag.  The operation's work methods (-start, -main, and whatever  
they call) should be periodically checking the -isCancelled property  
and, if it's set, gracefully bring their work to an end.


Because all -start does is initiate an NSURLConnection. If it's  
failing to connect or whatever, I want the operation to stop when the  
user says so, not whenever -didFailWithError gets around to being  
called.


--
Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/

"You definitely have some kind of Zen thing going for you."
   -- Craig Joseph Huxtable

___

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 do I make one thread wait until another thread exits?

2009-02-13 Thread Michael Ash
On Thu, Feb 12, 2009 at 11:08 AM, Oleg Krupnov  wrote:
> Thanks, Mike.
>
> I assume that I need to also use
>
> #define OPERATION_NOT_FINISHED 0
>
> and
>
> condLock = [[NSConditionLock alloc] initWithCondition: 
> OPERATION_NOT_FINISHED];
>
> Right?

Strictly speaking this is unnecessary. NSConditionLock is documented
to start out at condition 0. However, being more explicit is usually a
good idea, so why not.

> I have a doubt here, however. What if the cancel message is sent even
> before the worker thread had the possibility to start? In that case,
> the NSOperation may remove itself from the queue and never start its
> worker thread altogether. Than the main thread will deadlock because
> the condition will never be OPERATION_FINISHED. How to fix this?

You're right, I hadn't thought of this.

I believe the answer is to have four conditions:

0) NOT_STARTED
1) SHOULD_QUIT
2) RUNNING
3) FINISHED

When the operation starts, it does something like this:

BOOL shouldQuit = NO;
[condLock lock]
shouldQuit = [condLock condition] == SHOULD_QUIT
[condLock unlockWithCondition:RUNNING];
if(!shouldQuit) {
   ...do your work here...
}
[condLock lock];
[condLock unlockWithCondition:FINISHED];

And then when you cancel it:

[operation cancel];
BOOL isRunning = NO;
[condLock lock];
isRunning = [condLock condition] == RUNNING;
if(!isRunning)
[condLock unlockWithCondition:SHOULD_QUIT];
[condLock unlock];
if(isRunning) {
[condLock lockWhenCondition:FINISHED];
[condLock unlock];
}

I think that will do everything. By checking the condition lock at the
top of your operation and bailing out early, it lets you cancel the
operation and then not care if it will never run, or if it will run
but be cancelled early on. If the operation has already started, then
it goes back to the original suggestion.

Mike
___

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: Proper NSOperation isCancelled handling

2009-02-13 Thread Kyle Sluder
On Fri, Feb 13, 2009 at 8:55 AM, Alex Curylo  wrote:
> Because all -start does is initiate an NSURLConnection. If it's failing to
> connect or whatever, I want the operation to stop when the user says so, not
> whenever -didFailWithError gets around to being called.

That's not what -cancel is supposed to do.  -cancel is simply a way to
get -isCancelled to return YES.  You check for this at the top of your
thread's runloop, and if it is YES then you abort your operation and
end the thread.

--Kyle Sluder
___

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: System Preferences "halo/spotlight" effect

2009-02-13 Thread Kyle Sluder
On Fri, Feb 13, 2009 at 7:51 AM, John C. Daub  wrote:
> I'm figuring in System Preferences it's using an overlay window, but since
> my content scrolls I cannot use a window and must use an NSView. I did find
> -[NSView addSubview:positioned:relativeTo:], which helped me position my
> "halo view" atop my contents, and I have been fiddling around with various
> things trying to accomplish the effect but I can't quite get there. I do see
> within System Preferences.app/Contents/Resources/ a spotlight.tif and
> spotlightdim.tif which provide the halo masking, and I experimenting with
> rendering copies of those TIFF's via
> -drawAtPoint:fromRect:operation:fraction: within my -[HaloView drawRect:]
> and I could sorta get things to work with a fraction of 0.5. But that just
> gives me the halo. I'm struggling to get the fill over the full content
> area, that then doesn't affect the halo areas.

1) Why can't you use an overlay window?  Just convert to window
coordinates and clip appropriately when objects are out of view.
2) If you want to go the image route, I'd use a Quartz mask.  Saves
you from having to render the blur at runtime.

--Kyle Sluder
___

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 do I make one thread wait until another thread exits?

2009-02-13 Thread James Bucanek
Oleg Krupnov  wrote (Thursday, 
February 12, 2009 9:08 AM +0200):



Thanks, Mike.

I assume that I need to also use

#define OPERATION_NOT_FINISHED 0

and

condLock = [[NSConditionLock alloc] initWithCondition: OPERATION_NOT_FINISHED];

Right?

I have a doubt here, however. What if the cancel message is sent even
before the worker thread had the possibility to start? In that case,
the NSOperation may remove itself from the queue and never start its
worker thread altogether. Than the main thread will deadlock because
the condition will never be OPERATION_FINISHED. How to fix this?


A three state condition lock. I do this all the time (typed in mail):

enum {
OPERATION_INIT,
OPERATION_RUNNING,
OPERATION_FINISHED };

-- operation --

- (id)init {
...
conditionLock = [[NSConditionLock alloc] initWithCondition: OPERATION_INIT];
...

- (void)main {
[conditionLock lock];
[conditionLock unlockWithCondition:OPERATION_RUNNING];

// do stuff

[conditionLock lock];
[conditionLock unlockWithCondition:OPERATION_FINISHED];
}

-- other thread --

// to wait until the operation thread finishes
[operation->condtionLock lockWhenCondition:OPERATION_FINISHED];
[operation->condtionLock unlock];

(note that I usually encapsulate this in a 
-(void)waitUntilFinished method)


James
--
James Bucanek

___

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: isNotEqualToString

2009-02-13 Thread Gordon Apple
Or just replace the "||" with "&&".  DeMorgan's theorem.   Basic boolean
logic.


On 2/13/09 3:19 AM, "cocoa-dev-requ...@lists.apple.com"
 wrote:

> Subject: Re: isNotEqualToString
> To: Chunk 1978 
> Cc: cocoa-dev Dev 
> Message-ID: 
> Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes
> 
> 
> On 13 Feb 2009, at 10:00, Chunk 1978 wrote:
> 
>> -=-=-=-
>> if ((![currentDesktopBackgroundImage isEqualToString:firstPath]) ||
>> (![currentDesktopBackgroundImage isEqualToString:secondPath]))
>> {
>> //Go South
>> }
> 
> lets assume that currentDesktopBackgroundImage IS firstPath (and that
> secondPath ≠ firstPath)
> 
> The first portion of your test gives false so it tries the second
> portion.
> This gives true, since currentDesktopBackgroundImage ≠ secondPath
> 
> so you go south. Your version will always Go South UNLESS
> currentDesktopBackgroundImage == firstPath == secondPath
> 
> I think you want this;
> 
> if (!([currentDesktopBackgroundImage isEqualToString:firstPath] ||
> [currentDesktopBackgroundImage isEqualToString:secondPath]))
> {
> //Go South
> }
> 
> Matt
> 
> --

G. Apple



___

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: System Preferences "halo/spotlight" effect

2009-02-13 Thread Adam R. Maxwell


On Feb 13, 2009, at 4:51 AM, John C. Daub wrote:

I'm trying to replicate that overlay halo/spotlight behavior, in a  
similar

sort of window (window full of icons). I'm seeking guidance in how to
achieve this.


I did this on an OmniAppKit preference window, and it works pretty  
well using an overlay window and custom view.  Code is all BSD licensed:


View:

http://bibdesk.svn.sourceforge.net/viewvc/bibdesk/trunk/bibdesk/BDSKSpotlightView.m?view=markup

Controller:

http://bibdesk.svn.sourceforge.net/viewvc/bibdesk/trunk/bibdesk/BDSKPreferenceController.m?view=markup

Overlay window:

http://bibdesk.svn.sourceforge.net/viewvc/bibdesk/trunk/bibdesk/BDSKOverlay.m?view=markup




smime.p7s
Description: S/MIME cryptographic signature
___

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

NSCollectionView inside an NSSplitView?

2009-02-13 Thread Jean-Nicolas Jolivet
I'm having weird problems with a CollectionView inside an  
NSSplitView... it looks fine but as soon as I re-size (either by  
dragging the split view's divider or by re-sizing the window) the  
CollectionView's animation is flickering a LOT, and the items in my  
collection view are jumping all over the place, from the top of the  
collection view to the bottom and back to the top...


I was wondering if anyone else had problems with NSCollectionView in  
split views? I'm pretty sure the problem is related to animation...  
perhaps if I could disable the collection view's animation altogether?  
Not sure if it's possible...


I first noticed the bug using BWToolKit's BWSplitView and I thought it  
could be a bug with the toolkit, but I tried changing the BWSplitView  
to an NSSplitView and the same behavior is present...


It's really nothing subtle... it really makes the app unusable... is  
this a known bug?


Jean-Nicolas Jolivet
silver...@videotron.ca
http://www.silverscripting.com

___

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 inside an NSSplitView?

2009-02-13 Thread Randall Meadows

On Feb 13, 2009, at 11:09 AM, Jean-Nicolas Jolivet wrote:

I'm having weird problems with a CollectionView inside an  
NSSplitView... it looks fine but as soon as I re-size (either by  
dragging the split view's divider or by re-sizing the window) the  
CollectionView's animation is flickering a LOT, and the items in my  
collection view are jumping all over the place, from the top of the  
collection view to the bottom and back to the top...


I was wondering if anyone else had problems with NSCollectionView in  
split views? I'm pretty sure the problem is related to animation...  
perhaps if I could disable the collection view's animation  
altogether? Not sure if it's possible...


I first noticed the bug using BWToolKit's BWSplitView and I thought  
it could be a bug with the toolkit, but I tried changing the  
BWSplitView to an NSSplitView and the same behavior is present...


It's really nothing subtle... it really makes the app unusable... is  
this a known bug?


I have a feeling it's related to the problem I had with doing live  
zooming of an IKImageView; during the live zooming, the animation  
would stutter constantly, just as you describe, as the zoom factor got  
set, triggering the animation, and then because it was live zooming,  
the zoom factor would get set again, again triggering the animation,  
but the animation was already in progress, so it got b0rked.  I was  
told I should be able to disable the animations, but never could, so I  
ended up writing my own replacement for the IKImageView that behaved  
correctly.  I have a feeling you're hitting the same (or at least  
similar) issue.


___

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


Retrieving the distinct values of an attribute for a Core Data entity

2009-02-13 Thread Jon C. Munson II
Namaste!

I'm hoping someone can point me in the right direction for the following.
I'm not sure what search terms to use, so I was blindly groping around
before I wrote the list.

I need to retrieve the distinct values of a given attribute in a Core Data
entity.

In SQL, this is trivial:  "SELECT column FROM table GROUP BY column;"

How is this accomplished in the Core Data context?

Many thanks in advance! 

Peace, Love, and Light,

/s/ Jon C. Munson II



___

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: Window Max Zoom Size

2009-02-13 Thread Anthony Smith
I'm surprised there isn't a maxZoomSize or something. This doesn't  
look like it deals with zoom just resizing in general. I'm new to Mac  
development so I could just be missing something. Thanks for the input!


Anthony Smith


On Feb 12, 2009, at 11:39 PM, John C. Randolph wrote:



On Feb 12, 2009, at 9:42 AM, Anthony Smith wrote:

What is the best way to set the max zoom size for NSWindow? I was  
able to implement a solution by overriding zoom but that feels  
rather invasive so I'm assuming there's probably a better way.


Check the docs for -windowWillResize:toSize:.

-jcr




___

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: Retrieving the distinct values of an attribute for a Core Data entity

2009-02-13 Thread I. Savant
On Fri, Feb 13, 2009 at 1:25 PM, Jon C. Munson II  wrote:

> I need to retrieve the distinct values of a given attribute in a Core Data
> entity.

  It's important to remember that Core Data is not a database system.
It shares things in common, but because that is not its focus, there
are things you may have to do for yourself.

  For example, I don't know that this is possible within a fetch
request (via a predicate), but I do know that you can fetch the
non-distinct data you want and use an array or set operator (
[myResults valueForKeyPath:@"@distinctUnionOfSets.foo"] ) to get the
distinct list of "foo" values. There are other set and array operators
as well:

http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/ArrayOperators.html

  Is that what you're asking?

--
I.S.
___

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: Retrieving the distinct values of an attribute for a Core Data entity

2009-02-13 Thread I. Savant
On Fri, Feb 13, 2009 at 2:08 PM, I. Savant  wrote:

>  For example, I don't know that this is possible within a fetch
> request (via a predicate), but I do know that you can fetch the
> non-distinct data you want and use an array or set operator ...

  Just to clarify the very confused statement above: This problem has
to do with keypaths, not predicates. I muddled my statement because I
was thinking about the fact that some predicate tokens are disallowed
depending on the store type. I'm pretty sure @distinctUnionOfSets and
other operators are supported on all store types, but I'm not sure.

--
I.S.
___

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: Retrieving the distinct values of an attribute for a Core Data entity

2009-02-13 Thread Jon C. Munson II
Namaste!

Yes, 'twas and is indeed.  That, I believe answers my question.

Many thanks!

Peace, Love, and Light,

/s/ Jon C. Munson II


> -Original Message-
> From: I. Savant [mailto:idiotsavant2...@gmail.com]
> Sent: Friday, February 13, 2009 2:08 PM
> To: jmun...@his.com
> Cc: Cocoa-Dev List
> Subject: Re: Retrieving the distinct values of an attribute for a Core
> Data entity
> 
> On Fri, Feb 13, 2009 at 1:25 PM, Jon C. Munson II  wrote:
> 
> > I need to retrieve the distinct values of a given attribute in a Core
> Data
> > entity.
> 
>   It's important to remember that Core Data is not a database system.
> It shares things in common, but because that is not its focus, there
> are things you may have to do for yourself.
> 
>   For example, I don't know that this is possible within a fetch
> request (via a predicate), but I do know that you can fetch the
> non-distinct data you want and use an array or set operator (
> [myResults valueForKeyPath:@"@distinctUnionOfSets.foo"] ) to get the
> distinct list of "foo" values. There are other set and array operators
> as well:
> 
> http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/C
> oncepts/ArrayOperators.html
> 
>   Is that what you're asking?
> 
> --
> I.S.

___

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: Window Max Zoom Size

2009-02-13 Thread Ken Thomases

On Feb 13, 2009, at 1:06 PM, Anthony Smith wrote:

I'm surprised there isn't a maxZoomSize or something. This doesn't  
look like it deals with zoom just resizing in general. I'm new to  
Mac development so I could just be missing something. Thanks for the  
input!


You want the -windowWillUseStandardFrame:defaultFrame: delegate  
method.  Its return value is the "best" size for the window.


Cheers,
Ken

___

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: Window Max Zoom Size

2009-02-13 Thread Andy Lee
Did you look closely at the docs for zoom: before overriding it?  Did  
you try Joar's suggestion to look at NSWindow's delegate methods?   
What I'm getting at is... I think  
windowWillUseStandardFrame:defaultFrame: is what you want, though I  
haven't tried it myself.


--Andy


On Feb 13, 2009, at 2:06 PM, Anthony Smith wrote:

I'm surprised there isn't a maxZoomSize or something. This doesn't  
look like it deals with zoom just resizing in general. I'm new to  
Mac development so I could just be missing something. Thanks for the  
input!


Anthony Smith


On Feb 12, 2009, at 11:39 PM, John C. Randolph wrote:



On Feb 12, 2009, at 9:42 AM, Anthony Smith wrote:

What is the best way to set the max zoom size for NSWindow? I was  
able to implement a solution by overriding zoom but that feels  
rather invasive so I'm assuming there's probably a better way.


Check the docs for -windowWillResize:toSize:.

-jcr




___

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/aglee%40mac.com

This email sent to ag...@mac.com


___

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: Window Max Zoom Size

2009-02-13 Thread Anthony Smith
That looks like it makes sense. I'm assuming -zoom: is only called  
when being zoomed in and not zoomed out. Is that correct or do I need  
to detect which way it's zooming?


On Feb 13, 2009, at 2:15 PM, Ken Thomases wrote:


On Feb 13, 2009, at 1:06 PM, Anthony Smith wrote:

I'm surprised there isn't a maxZoomSize or something. This doesn't  
look like it deals with zoom just resizing in general. I'm new to  
Mac development so I could just be missing something. Thanks for  
the input!


You want the -windowWillUseStandardFrame:defaultFrame: delegate  
method.  Its return value is the "best" size for the window.


Cheers,
Ken



___

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: Window Max Zoom Size

2009-02-13 Thread Jean-Daniel Dupas

Le 13 févr. 09 à 20:15, Ken Thomases a écrit :


On Feb 13, 2009, at 1:06 PM, Anthony Smith wrote:

I'm surprised there isn't a maxZoomSize or something. This doesn't  
look like it deals with zoom just resizing in general. I'm new to  
Mac development so I could just be missing something. Thanks for  
the input!


You want the -windowWillUseStandardFrame:defaultFrame: delegate  
method.  Its return value is the "best" size for the window.



I don't understand what you mean by "zoom size", but  If you're  
looking for a max window size, you can set it in IB, in the size  
settings, or using the -[NSWindow setMaxSize:]



___

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 inside an NSSplitView?

2009-02-13 Thread Markus Spoettl

On Feb 13, 2009, at 7:09 PM, Jean-Nicolas Jolivet wrote:
I'm having weird problems with a CollectionView inside an  
NSSplitView... it looks fine but as soon as I re-size (either by  
dragging the split view's divider or by re-sizing the window) the  
CollectionView's animation is flickering a LOT, and the items in my  
collection view are jumping all over the place, from the top of the  
collection view to the bottom and back to the top...


I was wondering if anyone else had problems with NSCollectionView in  
split views? I'm pretty sure the problem is related to animation...  
perhaps if I could disable the collection view's animation  
altogether? Not sure if it's possible...



I'm using an NSCollectionView and NSSplitView and this aspect works  
correctly, I'm seeing no weird animation flickering like you describe.  
NSCollectionView does have a different problem in that it resets the  
scroll positions to topmost/leftmost whenever the view is resized.  
Highly visible and annoying but probably not related to your issue.


Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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: Window Max Zoom Size

2009-02-13 Thread Anthony Smith

Sorry, I was backwards:

"I'm assuming -zoom: is only called when being zoomed out and not  
zoomed in."


On Feb 13, 2009, at 2:26 PM, Anthony Smith wrote:

That looks like it makes sense. I'm assuming -zoom: is only called  
when being zoomed in and not zoomed out. Is that correct or do I  
need to detect which way it's zooming?


On Feb 13, 2009, at 2:15 PM, Ken Thomases wrote:


On Feb 13, 2009, at 1:06 PM, Anthony Smith wrote:

I'm surprised there isn't a maxZoomSize or something. This doesn't  
look like it deals with zoom just resizing in general. I'm new to  
Mac development so I could just be missing something. Thanks for  
the input!


You want the -windowWillUseStandardFrame:defaultFrame: delegate  
method.  Its return value is the "best" size for the window.


Cheers,
Ken



___

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/anthony.c.smith%40comcast.net

This email sent to anthony.c.sm...@comcast.net


___

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: Window Max Zoom Size

2009-02-13 Thread Anthony Smith
When a zoom is performed on a window I want to be able to specify the  
width or height it will zoom out to. Similar to Safari/WebKit's  
variable zoom size.


On Feb 13, 2009, at 2:31 PM, Jean-Daniel Dupas wrote:


Le 13 févr. 09 à 20:15, Ken Thomases a écrit :


On Feb 13, 2009, at 1:06 PM, Anthony Smith wrote:

I'm surprised there isn't a maxZoomSize or something. This doesn't  
look like it deals with zoom just resizing in general. I'm new to  
Mac development so I could just be missing something. Thanks for  
the input!


You want the -windowWillUseStandardFrame:defaultFrame: delegate  
method.  Its return value is the "best" size for the window.



I don't understand what you mean by "zoom size", but  If you're  
looking for a max window size, you can set it in IB, in the size  
settings, or using the -[NSWindow setMaxSize:]





___

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: Window Max Zoom Size

2009-02-13 Thread Andy Lee

On Feb 13, 2009, at 2:39 PM, Anthony Smith wrote:

Sorry, I was backwards:

"I'm assuming -zoom: is only called when being zoomed out and not  
zoomed in."


I guess I would repeat my earlier question: did you look at the  
documentation for zoom:?  Hint: look at the first sentence.


--Andy





On Feb 13, 2009, at 2:26 PM, Anthony Smith wrote:

That looks like it makes sense. I'm assuming -zoom: is only called  
when being zoomed in and not zoomed out. Is that correct or do I  
need to detect which way it's zooming?


On Feb 13, 2009, at 2:15 PM, Ken Thomases wrote:


On Feb 13, 2009, at 1:06 PM, Anthony Smith wrote:

I'm surprised there isn't a maxZoomSize or something. This  
doesn't look like it deals with zoom just resizing in general.  
I'm new to Mac development so I could just be missing something.  
Thanks for the input!


You want the -windowWillUseStandardFrame:defaultFrame: delegate  
method.  Its return value is the "best" size for the window.


Cheers,
Ken



___

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/anthony.c.smith%40comcast.net

This email sent to anthony.c.sm...@comcast.net


___

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/aglee%40mac.com

This email sent to ag...@mac.com


___

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: Window Max Zoom Size

2009-02-13 Thread Clark Cox
On Fri, Feb 13, 2009 at 11:40 AM, Anthony Smith
 wrote:
> When a zoom is performed on a window I want to be able to specify the width
> or height it will zoom out to. Similar to Safari/WebKit's variable zoom
> size.

People have already pointed to the
-windowWillUseStandardFrame:defaultFrame: delegate method. This is
exactly what you need. Implement that method on your window's
delegate, and return the rectangle that you want to use for the zoomed
state.

You're doing yourself a disservice not reading the documentation that
many people have pointed you to so far.

-- 
Clark S. Cox III
clarkc...@gmail.com
___

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: System Preferences "halo/spotlight" effect

2009-02-13 Thread John C. Daub
on 2/13/09 10:26 AM, Kyle Sluder at kyle.slu...@gmail.com wrote:

> On Fri, Feb 13, 2009 at 7:51 AM, John C. Daub  wrote:
>> I'm figuring in System Preferences it's using an overlay window, but since
>> my content scrolls I cannot use a window and must use an NSView. I did find
>> -[NSView addSubview:positioned:relativeTo:], which helped me position my
>> "halo view" atop my contents, and I have been fiddling around with various
>> things trying to accomplish the effect but I can't quite get there. I do see
>> within System Preferences.app/Contents/Resources/ a spotlight.tif and
>> spotlightdim.tif which provide the halo masking, and I experimenting with
>> rendering copies of those TIFF's via
>> -drawAtPoint:fromRect:operation:fraction: within my -[HaloView drawRect:]
>> and I could sorta get things to work with a fraction of 0.5. But that just
>> gives me the halo. I'm struggling to get the fill over the full content
>> area, that then doesn't affect the halo areas.
> 
> 1) Why can't you use an overlay window?  Just convert to window
> coordinates and clip appropriately when objects are out of view.

Is there some particular reason why I ought to use an overlay window and not
just an NSView added via -addSubview:positioned:relativeTo: NSWindowAbove
relative to my content view?

> 2) If you want to go the image route, I'd use a Quartz mask.  Saves
> you from having to render the blur at runtime.

Adam R. Maxwell posted another reply and I took his approach.

Thanx for the reply.

-- 
John C. Daub }:-)>=
 
Too numb to cry, too tough to die. - BLS
 


___

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: System Preferences "halo/spotlight" effect

2009-02-13 Thread John C. Daub
on 2/13/09 10:41 AM, Adam R. Maxwell at amaxw...@mac.com wrote:

> On Feb 13, 2009, at 4:51 AM, John C. Daub wrote:
> 
>> I'm trying to replicate that overlay halo/spotlight behavior, in a
>> similar sort of window (window full of icons). I'm seeking guidance in
>> how to achieve this.
> 
> I did this on an OmniAppKit preference window, and it works pretty
> well using an overlay window and custom view.  Code is all BSD licensed:
> 
> View:
> 
> http://bibdesk.svn.sourceforge.net/viewvc/bibdesk/trunk/bibdesk/BDSKSpotlightV
> iew.m?view=markup
> 
> Controller:
> 
> http://bibdesk.svn.sourceforge.net/viewvc/bibdesk/trunk/bibdesk/BDSKPreference
> Controller.m?view=markup
> 
> Overlay window:
> 
> http://bibdesk.svn.sourceforge.net/viewvc/bibdesk/trunk/bibdesk/BDSKOverlay.m?
> view=markup

Thank you for this!

I didn't use your code directly, but I followed what you did in the
BDSKSpotlightView source along with little bits from the other 2 and was
able to get something going. It's just proof of concept and plugging it into
my code right now, so I still have much work to do to get it working just
right for my needs. But this is exactly the sort of thing I needed.

Thank you for your help and for sharing this with me.

-- 
John C. Daub }:-)>=
 
"Nothing is greater than love or surrender." -- Buddo


___

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: Window Max Zoom Size

2009-02-13 Thread Sean McBride
On 2/13/09 8:31 PM, Jean-Daniel Dupas said:

>I don't understand what you mean by "zoom size"



--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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 inside an NSSplitView?

2009-02-13 Thread Jean-Nicolas Jolivet

I managed to capture it on video...
Here it is:

http://silvercocoa.com/flicker.mov


Basically I get this whether I resize the window or the split view  
(using the divider).
I also tried replacing my custom view (the rounded rectangle) with a  
regular NSView... still the same problem



On 13-Feb-09, at 1:09 PM, Jean-Nicolas Jolivet wrote:

I'm having weird problems with a CollectionView inside an  
NSSplitView... it looks fine but as soon as I re-size (either by  
dragging the split view's divider or by re-sizing the window) the  
CollectionView's animation is flickering a LOT, and the items in my  
collection view are jumping all over the place, from the top of the  
collection view to the bottom and back to the top...


I was wondering if anyone else had problems with NSCollectionView in  
split views? I'm pretty sure the problem is related to animation...  
perhaps if I could disable the collection view's animation  
altogether? Not sure if it's possible...


I first noticed the bug using BWToolKit's BWSplitView and I thought  
it could be a bug with the toolkit, but I tried changing the  
BWSplitView to an NSSplitView and the same behavior is present...


It's really nothing subtle... it really makes the app unusable... is  
this a known bug?


Jean-Nicolas Jolivet
silver...@videotron.ca
http://www.silverscripting.com

___

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/silvertab%40videotron.ca

This email sent to silver...@videotron.ca


Jean-Nicolas Jolivet
silver...@videotron.ca
http://www.silverscripting.com

___

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: Window Max Zoom Size

2009-02-13 Thread Anthony Smith
I have been reading the docs and I have stated that I do agree that - 
windowWillUseStandardFrame:defaultFrame: is what I want. I was trying  
to clarify to Jean what I meant by "zoom size" as he seemed to be  
confused by it.


My question is whether I need to detect and handle the direction of  
the zoom (presumably using -isZoomed:).


As per Andy's advice, the docs for -zoom: state:

"This action method toggles the size and location of the window  
between its standard state (provided by the application as the “best”  
size to display the window’s data) and its user state (a new size and  
location the user may have set by moving or resizing the window)."


This statement seems to imply that it's smart enough to know when it  
should execute -performZoom: based on the windows state.


So I think this answers my question.

Anthony Smith

On Feb 13, 2009, at 2:53 PM, Clark Cox wrote:


On Fri, Feb 13, 2009 at 11:40 AM, Anthony Smith
 wrote:
When a zoom is performed on a window I want to be able to specify  
the width
or height it will zoom out to. Similar to Safari/WebKit's variable  
zoom

size.


People have already pointed to the
-windowWillUseStandardFrame:defaultFrame: delegate method. This is
exactly what you need. Implement that method on your window's
delegate, and return the rectangle that you want to use for the zoomed
state.

You're doing yourself a disservice not reading the documentation that
many people have pointed you to so far.

--
Clark S. Cox III
clarkc...@gmail.com


___

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


NSRunLoop / CFRunLoop

2009-02-13 Thread Alexander Cohen

Hi,

Not sure if this is the right place to ask since my question is about  
CFRunLoop, not Cocoa but CoreFoundation. If not, please direct me to  
the right list.


I'm looking for a way to get the main CFRunLoop on tiger. On leopard,  
there is a simple call for it but i'm stuck with tiger for now. And  
while i'm at it, i'd like to do something like [obj  
performSelectorOnMainThread...] in CoreFoundation using CFRunLoops.  
I'm sure it's possible but i'm not sure where to start.


thx

AC
___

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 inside an NSSplitView?

2009-02-13 Thread Jean-Nicolas Jolivet
Well, after some tests, it appears I am getting the same result even  
without using an NSSplitView... so apparently the problem is  
elsewhere... I'm running out of ideas here hehe...




On 13-Feb-09, at 3:18 PM, Jean-Nicolas Jolivet wrote:


I managed to capture it on video...
Here it is:

http://silvercocoa.com/flicker.mov


Basically I get this whether I resize the window or the split view  
(using the divider).
I also tried replacing my custom view (the rounded rectangle) with a  
regular NSView... still the same problem



On 13-Feb-09, at 1:09 PM, Jean-Nicolas Jolivet wrote:

I'm having weird problems with a CollectionView inside an  
NSSplitView... it looks fine but as soon as I re-size (either by  
dragging the split view's divider or by re-sizing the window) the  
CollectionView's animation is flickering a LOT, and the items in my  
collection view are jumping all over the place, from the top of the  
collection view to the bottom and back to the top...


I was wondering if anyone else had problems with NSCollectionView  
in split views? I'm pretty sure the problem is related to  
animation... perhaps if I could disable the collection view's  
animation altogether? Not sure if it's possible...


I first noticed the bug using BWToolKit's BWSplitView and I thought  
it could be a bug with the toolkit, but I tried changing the  
BWSplitView to an NSSplitView and the same behavior is present...


It's really nothing subtle... it really makes the app unusable...  
is this a known bug?


Jean-Nicolas Jolivet
silver...@videotron.ca
http://www.silverscripting.com

___

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/silvertab%40videotron.ca

This email sent to silver...@videotron.ca


Jean-Nicolas Jolivet
silver...@videotron.ca
http://www.silverscripting.com



Jean-Nicolas Jolivet
silver...@videotron.ca
http://www.silverscripting.com

___

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 inside an NSSplitView?

2009-02-13 Thread Markus Spoettl

On Feb 13, 2009, at 10:02 PM, Jean-Nicolas Jolivet wrote:
Well, after some tests, it appears I am getting the same result even  
without using an NSSplitView... so apparently the problem is  
elsewhere... I'm running out of ideas here hehe...



Judging from the video it appears that you resize the item views  
contained in the NSCollectionView when it's resized. There must be  
some weird interaction going on. What happens if you disable the  
resizing of the NSCollectionView item views?


Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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: Binding to custom NSCell [Solved]

2009-02-13 Thread Corbin Dunn


On Feb 12, 2009, at 8:53 PM, Ken Tozier wrote:

After looking at NSActionCell, I noticed the "setControlView" method  
and this seems to be the missing link. NSActionCell sets it's  
control view while NSCell does not. When I manually set the control  
view for my custom cell to the table that contains it, viola! It  
works.


So, for any other NSCell subclassers out there, the progression of  
steps is


MyCell  *cell   = [[[MYCell alloc] init] autorelease];
NSTableColumn   *column = [[[NSTableColumn alloc] init] autorelease];
NSTableView *table  = [[NSTableView alloc] initWithFrame: aFrame];

[cell setControlView: table];
[column setDataCell: cell];
[table addTableColumn: column];

[column bind: @"value" toObject: arrayController withKeyPath:  
@"arrangedObjects." options: nil];


Hope this saves someone else a lost couple of days figuring this  
out...


As I mentioned before, logging a bug would be very useful; even if it  
is to just increase our documentation for how to do this. If you don't  
have the time to do so, also please let us know, as I will log the bug  
for you.


thanks,

corbin



___

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


Programatically Uncheck "Change Picture" In Desktop Settings?

2009-02-13 Thread Chunk 1978
is this possible?  it seems that programatically changing
com.apple.desktop.plist (Background > Default > Change) from
TimeInterval to Never will not override the settings in System
Preferences.  i though applescript could be an option but it seems
that using an applescript to accomplish this would have to open the
system preferences window.  it's only ideal if it's done as a
background process.
___

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 inside an NSSplitView?

2009-02-13 Thread Jean-Nicolas Jolivet
If I disable the item's re-sizing, the behavior is less apparent...  
it's still a little odd (sometimes the items are attached to the right  
side of the collection viewthen all of a sudden they go back to  
their original place etc..)  but it's definitely not as bad...  
however, obviously, my items don't get re-sized... which isn't really  
how I need it to behave...




On 13-Feb-09, at 4:24 PM, Markus Spoettl wrote:


On Feb 13, 2009, at 10:02 PM, Jean-Nicolas Jolivet wrote:
Well, after some tests, it appears I am getting the same result  
even without using an NSSplitView... so apparently the problem is  
elsewhere... I'm running out of ideas here hehe...



Judging from the video it appears that you resize the item views  
contained in the NSCollectionView when it's resized. There must be  
some weird interaction going on. What happens if you disable the  
resizing of the NSCollectionView item views?


Regards
Markus
--
__
Markus Spoettl

___

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/silvertab%40videotron.ca

This email sent to silver...@videotron.ca


Jean-Nicolas Jolivet
silver...@videotron.ca
http://www.silverscripting.com

___

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: Programatically Uncheck "Change Picture" In Desktop Settings?

2009-02-13 Thread I. Savant

On Feb 13, 2009, at 4:30 PM, Chunk 1978 wrote:


is this possible?  it seems that programatically changing
com.apple.desktop.plist (Background > Default > Change) from
TimeInterval to Never will not override the settings in System
Preferences.  i though applescript could be an option but it seems
that using an applescript to accomplish this would have to open the
system preferences window.  it's only ideal if it's done as a
background process.


  No, changing the preferences file certainly won't prompt the  
preferences to be reloaded. You need to go through the preferences  
system itself. You're essentially trying to change an open text  
document's content in a text editor by rewriting its file on disk ...


http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/UserDefaults/Concepts/DefaultsDomains.html

  I don't know if all defaults domains are available for  
manipulation, but you need to go through the defaults system instead  
of modifying files behind its back.


--
I.S.

___

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: Programatically Uncheck "Change Picture" In Desktop Settings?

2009-02-13 Thread Nick Zitzmann


On Feb 13, 2009, at 2:30 PM, Chunk 1978 wrote:


is this possible?  it seems that programatically changing
com.apple.desktop.plist (Background > Default > Change) from
TimeInterval to Never will not override the settings in System
Preferences.



What exactly are you trying to accomplish?

Nick Zitzmann


___

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: Programatically Uncheck "Change Picture" In Desktop Settings?

2009-02-13 Thread Chunk 1978
i'm trying to set the desktop background from an app, but i've noticed
that it will not work if the user has their desktop settings set to
change.  so i'm trying to uncheck "Change Picture" from the System
Prefs (or change TimeInterval to Never in the com.apple.desktop.plist)
before setting the new desktop background.

On Fri, Feb 13, 2009 at 4:37 PM, Nick Zitzmann  wrote:
>
> On Feb 13, 2009, at 2:30 PM, Chunk 1978 wrote:
>
>> is this possible?  it seems that programatically changing
>> com.apple.desktop.plist (Background > Default > Change) from
>> TimeInterval to Never will not override the settings in System
>> Preferences.
>
>
> What exactly are you trying to accomplish?
>
> Nick Zitzmann
> 
>
>
___

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: Converting a CMYK NSImage to RGB

2009-02-13 Thread Ken Ferry
Hi Ron,
It was the -[NSImage lockFocus]/-[NSImage unlockFocus] that did it.  You
should just take them out, they weren't relevant to what you were trying to
do.

-[NSImage lockFocus] sets the receiver up as a drawing _destination_.  You
aren't trying to draw into the image here, you're trying to draw _from_ it.

lockFocus will
(1) Create a buffer.
(2) Make the buffer the current drawing graphics context, so that methods
like NSRectFill are directed to the buffer.
(3) Draw the existing contents of the image into the new buffer.

unlockFocus will
(4) pop the current graphics context back to whatever it was before
lockFocus was called.
(5) take the contents of the buffer and make them the new contents of the
image.

In particular, lockFocus/unlockFocus is necessarily destructive.  The old
image representations are discarded, replaced with a new one.

-Ken

On Thu, Feb 12, 2009 at 5:52 PM, Ron Aldrich  wrote:

> Folks,
>
> I'm having an issue where CMYK images aren't being recognized by my quartz
> compositions, so I need to convert them to RGB for display.
>
> I've written a routine to do it, but its causing problems.
>
>  NSImageRep* theImageRep = [inputImage bestRepresentationForDevice:
> [NSDictionary dictionaryWithObject: NSDeviceRGBColorSpace
>
>   forKey: NSDeviceColorSpaceName]];
>
>  NSString* theColorSpace = [theImageRep colorSpaceName];
>
>  if ([theColorSpace isEqualToString: NSDeviceCMYKColorSpace])
>  {
>NSBitmapImageRep* theRGBImageRep = [[[NSBitmapImageRep alloc]
> initWithBitmapDataPlanes: NULL
>
>pixelsWide: [theImageRep pixelsWide]
>
>pixelsHigh: [theImageRep pixelsHigh]
>
> bitsPerSample: 8
>
> samplesPerPixel: 4
>
>  hasAlpha: YES
>
>  isPlanar: NO
>
>  colorSpaceName: NSDeviceRGBColorSpace
>
>   bytesPerRow: 0
>
>  bitsPerPixel: 0] autorelease];
>
>[inputImage lockFocus];
>
>NSGraphicsContext* theContext = [NSGraphicsContext
> graphicsContextWithBitmapImageRep: theRGBImageRep];
>[NSGraphicsContext saveGraphicsState];
>[NSGraphicsContext setCurrentContext: theContext];
>
>NSRect theBoundsRect = NSMakeRect(0.0, 0.0, [theRGBImageRep pixelsWide],
> [theRGBImageRep pixelsHigh]);
>
>[[NSColor clearColor] set];
>NSRectFill(theBoundsRect);
>
>[theImageRep drawInRect: theBoundsRect];
>
>[NSGraphicsContext restoreGraphicsState];
>
>[inputImage unlockFocus];
>
>ASSIGNOBJECT(rgbImage, [[[NSImage alloc] initWithSize: [theImageRep
> size]] autorelease]);
>
>[rgbImage addRepresentation: theRGBImageRep];
>  }
>  else
>  {
>ASSIGNOBJECT(rgbImage, inputImage);
>  }
>
> The resulting image is correct, but somewhere along the line, my original
> image (inputImage) is being modified - the CMYK representation is being
> removed, and replaced with a downsampled RGB representation.  The goal here
> was to leave inputImage unmodified, so that when it is finally sent to the
> printer, the CMYK representation would be used.
>
> inputImage before creating the RGB version.
>
> NSImage 0x12313dd0 Size={340.08, 340.08} Reps=(
>NSBitmapImageRep 0xd8201c0 Size={340.08, 340.08}
> ColorSpace=NSDeviceCMYKColorSpace BPS=8 BPP=32 Pixels=1417x1417 Alpha=NO
> Planar=NO Format=0
> )
>
> inputImage after creating the RGB version.
>
> NSImage 0x12313dd0 Size={340.08, 340.08} Reps=(
>NSCachedImageRep 0xd824530 Size={340, 340}
> ColorSpace=NSCalibratedRGBColorSpace BPS=8 Pixels=340x340 Alpha=NO
> )
>
> Clearly, I'm doing something wrong.  I added calls to [inputImage
> lockFocus] and [inputImage unlockFocus] in order to resolve a multi-thread
> problem, but that seems to have caused this problem.
>
> So, what's the best way for me to convert an NSImage of unknown pedigree to
> a simple RGB representation?
>
> Thanks,
>
> Ron Aldrich
> Software Architects, Inc.
>
> ___
>
> 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/kenferry%40gmail.com
>
> This email sent to kenfe...@gmail.com
>
___

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 / CFRunLoop

2009-02-13 Thread Jean-Daniel Dupas


Le 13 févr. 09 à 21:54, Alexander Cohen a écrit :


Hi,

Not sure if this is the right place to ask since my question is  
about CFRunLoop, not Cocoa but CoreFoundation. If not, please direct  
me to the right list.


I'm looking for a way to get the main CFRunLoop on tiger. On  
leopard, there is a simple call for it but i'm stuck with tiger for  
now. And while i'm at it, i'd like to do something like [obj  
performSelectorOnMainThread...] in CoreFoundation using CFRunLoops.  
I'm sure it's possible but i'm not sure where to start.


thx


To get the main runloop, you can save it in a global variable at  
program startup, and return it when requested.


There is no easy way to mimic performSelectorOnMainThread: as there is  
no easy way to serialize a function call (unlike in Cocoa where you  
can easily serialize a method call using NSInvocation to send it on  
the main thread).


To do inter-thread messaging using only low-level frameworks, you are  
stuck with the traditional facilities (socket, pipes, etc.)


Just by curiosity, what prevent you to use the Foundation framework ?

___

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 crash when selected.

2009-02-13 Thread Harry Plate
I am struggling w/ a crash in my first Cocoa app that is using a TableView.

Some history: my app and its table view was working just fine when I was
simply adding NSString objects to the table.

Then I started using NSAttributedString instead so I could get the display
ellipses.

Now after dragging 2 (or more) elements into the view, if I simply click on
the table. Boom.

It is wierd that iff there is only 1 element in the table view, then all is
ok.

The stack is added below.

Appreciate any suggestions,

-harry


OS Version:  Mac OS X 10.5.5 (9F33)
Report Version:  6

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0xc031ec6b
Crashed Thread:  0

Thread 0 Crashed:
0   libobjc.A.dylib   0x95e7c688 objc_msgSend + 24
1   com.apple.Foundation  0x96482c4d
-[NSConcreteAttributedString initWithAttributedString:] + 61
2   com.apple.AppKit  0x93939dcc -[NSCell _setContents:] +
82
3   com.apple.AppKit  0x9394e1f2 -[NSCell setObjectValue:] +
50
4   com.apple.AppKit  0x9394e0eb -[NSActionCell
setObjectValue:] + 193
5   com.apple.AppKit  0x939f6054 -[NSTableView
preparedCellAtColumn:row:] + 304
6   com.apple.AppKit  0x939f5e44 -[NSTableView
_drawContentsAtRow:column:withCellFrame:] + 56
7   com.apple.AppKit  0x939f537a -[NSTableView
drawRow:clipRect:] + 872
8   com.apple.AppKit  0x9399a7f4 -[NSTableView
drawRowIndexes:clipRect:] + 363
9   com.apple.AppKit  0x939992d8 -[NSTableView drawRect:] +
2199
10  com.apple.AppKit  0x93a29864 -[NSView _drawRect:clip:] +
3853

...


___

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 / CFRunLoop

2009-02-13 Thread Ken Thomases

On Feb 13, 2009, at 2:54 PM, Alexander Cohen wrote:

I'm looking for a way to get the main CFRunLoop on tiger. On  
leopard, there is a simple call for it but i'm stuck with tiger for  
now.


Your main thread, before any secondary threads are created, can get  
its current run loop and stash a reference to it in a global variable.


And while i'm at it, i'd like to do something like [obj  
performSelectorOnMainThread...] in CoreFoundation using CFRunLoops.  
I'm sure it's possible but i'm not sure where to start.


You'd create a custom run loop source.  It would manage a queue of  
messages.  Access to the queue would have to be properly thread-safe.   
Your function for queuing a message would put it in the data structure  
and then signal your run loop source.  The "perform" callback of the  
run loop source would dequeue all of the messages and process them.


What you put in your messages and how you process them is entirely up  
to you.


There's a dated-but-still-nice bit of code out there called  
YAMessageQueue.  It has an Objective-C interface, but under the hood  
uses Core Foundation.  It might be educational.


Cheers,
Ken

___

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 crash when selected.

2009-02-13 Thread Shawn Erickson
On Fri, Feb 13, 2009 at 2:17 PM, Harry Plate  wrote:
> I am struggling w/ a crash in my first Cocoa app that is using a TableView.
>
> Some history: my app and its table view was working just fine when I was
> simply adding NSString objects to the table.
>
> Then I started using NSAttributedString instead so I could get the display
> ellipses.
>
> Now after dragging 2 (or more) elements into the view, if I simply click on
> the table. Boom.

As a guess you aren't retaining something you need to be retaining so
the object is disappearing on you.

Can you outline how you are creating and storing the values that you
have the table view display, etc.

-Shawn
___

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: Programatically Uncheck "Change Picture" In Desktop Settings?

2009-02-13 Thread Ken Thomases

On Feb 13, 2009, at 3:30 PM, Chunk 1978 wrote:


is this possible?  it seems that programatically changing
com.apple.desktop.plist (Background > Default > Change) from
TimeInterval to Never will not override the settings in System
Preferences.  i though applescript could be an option but it seems
that using an applescript to accomplish this would have to open the
system preferences window.  it's only ideal if it's done as a
background process.


You want to target System Events rather than System Preferences with  
your AppleScript.


Contrary to I. Savant, I don't think going through NSUserDefaults or  
CFPreferences will work.  It still won't inform the necessary  
processes of the change in an active manner.


Take a look at the LoginItemsAE sample code.  


Obviously, you're not working with Login Items, but it demonstrates  
the technique of sending Apple Events to System Events.  Also,  
modifying the user's login items has some conceptual similarities to  
what you're trying to do.  You might be tempted to modify the list of  
login items by manipulating the relevant .plist file, or by using  
NSUserDefaults or CFPreferences, but that's not appropriate.  The main  
failing is that, if the user actually has the Login Items tab of the  
Accounts pane of System Preferences open, changes you make to the  
preferences won't be reflected there.  Furthermore, the pane may at  
any time re-save what it thinks is the current state of the list,  
obliterating the change you attempted to make behind its back.


(Ironically, the new shiny way to manipulate Login Items is the  
LSSharedFileList API, not this sample code.  That API is currently  
only documented in .)


Cheers,
Ken

___

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 / CFRunLoop

2009-02-13 Thread Michael Ash
On Fri, Feb 13, 2009 at 5:21 PM, Ken Thomases  wrote:
>> And while i'm at it, i'd like to do something like [obj
>> performSelectorOnMainThread...] in CoreFoundation using CFRunLoops. I'm sure
>> it's possible but i'm not sure where to start.
>
> You'd create a custom run loop source.  It would manage a queue of messages.
>  Access to the queue would have to be properly thread-safe.  Your function
> for queuing a message would put it in the data structure and then signal
> your run loop source.  The "perform" callback of the run loop source would
> dequeue all of the messages and process them.

If all you need is fire and forget (i.e. you don't need to wait for
the message to complete) then you can do this by simply creating a
timer and adding it to the runloop. Don't forget to call
CFRunLoopWakeUp after you do this. CFRunLoop is thread safe, which
lets you do neat things like this.

(Don't let toll-free bridging confuse you: CFRunLoop is *not*
toll-free bridged to NSRunLoop, and NSRunLoop is *not* thread safe.)

Mike
___

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


alloc/release confusion

2009-02-13 Thread Boon Chew
Hi all,

I am very new to Cocoa programming (but have programmed in C/C++ before) and 
there is one thing I don't understand with alloc and release.  Sometimes I see 
code that alloc an object and release it within the same method, even though 
it's clear that the object is still live and well.

For example:

-(IBAction)onButtonPressed
{
  UIAlertView *alert = [[UIAlertView alloc] initWithTitle...];
  [alert show];
  [alert release];
}

Why is the code decrementing the ref count even though the alert window is 
still up?

Also, how do you know when you are decrementing ref count too soon? How do you 
know which object method you call might increase the ref count of the object in 
question?

Thanks!

- boon






  
___

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: alloc/release confusion

2009-02-13 Thread Kenny Leung

It's all detailed here:

http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html

-Kenny

___

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


Images In Dock Menu?

2009-02-13 Thread Chunk 1978
i have a NSMenu that i use as both a right-click menu and the dock
menu.  The images i use for some of the menu items will appear in the
right-click menu, but they do not show up in the dock menu.

i've connected the the File's Owner dockMenu to the NSMenu in IB so to
add the menu to the app's dock menu.  i've searched for an answer in
the archives, but it seems that this has been a "known issue" since
2003?
___

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: Proper NSOperation isCancelled handling

2009-02-13 Thread Ken Heglund


On Feb 13, 2009, at 8:23 AM, Kyle Sluder wrote:

On Fri, Feb 13, 2009 at 8:55 AM, Alex Curylo   
wrote:
Because all -start does is initiate an NSURLConnection. If it's  
failing to
connect or whatever, I want the operation to stop when the user  
says so, not

whenever -didFailWithError gets around to being called.


That's not what -cancel is supposed to do.  -cancel is simply a way to
get -isCancelled to return YES.  You check for this at the top of your
thread's runloop, and if it is YES then you abort your operation and
end the thread.


A -cancel override seems to be a fine place to clean up a cancelled  
concurrent operation.  If the operation's -start method registers for  
callbacks, or as a delegate, that needs to be undone at some point  
before the operation is deallocated.


In one case, I have operations that register as CFReadStream clients.   
A custom -cancel method closes the stream, cleans up the run loop, and  
calls [super cancel].  isCancelled KVO notifications are properly  
generated with no particular drama.


-Ken
___

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 crash when selected.

2009-02-13 Thread Corbin Dunn


Appreciate any suggestions,


Yes, here's the things I would do, in this order:

1. break on objc_exception_throw : 
http://www.corbinstreehouse.com/blog/index.php/2008/08/your-most-important-breakpoint-in-cocoa/
2. Use Instruments to find the over release: 
http://www.corbinstreehouse.com/blog/index.php/2007/10/instruments-on-leopard-how-to-debug-those-random-crashes-in-your-cocoa-app/
3. Make sure you properly implement -copyWithZone: if you have a  
custom cell


corbin
___

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


NSTreeController - Remove Children

2009-02-13 Thread none given

I have a NSTreeController with:
Node1
--- value1
--- value2
Node2
--- value1
--- value2
--- value3

With the following, I am able to remove a user selection:
 [treeController removeObjectsAtArrangedObjectIndexPaths:[treeController 
selectionIndexPaths]];

I cannot seem to find how to do this by code, that is, for example, remove from 
the tree all of Node2 children...

I tried with something like the following, but it only removes the node 
itself...

[treeController setSelectionIndexPath:[NSIndexPath indexPathWithIndex:1]];


How can I remove a node's children, while retaining the node itself?

Tia,

S.


  
___

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 inside an NSSplitView?

2009-02-13 Thread Jerry Krinock


On 2009 Feb 13, at 13:34, Jean-Nicolas Jolivet wrote:

If I disable the item's re-sizing, the behavior is less apparent...  
it's still a little odd (sometimes the items are attached to the  
right side of the collection viewthen all of a sudden they go  
back to their original place etc..)  but it's definitely not as bad


Yes, whenever I see stuff jumping around like in your movie I start  
sniffing around for an evil autoresize setting, and almost always find  
one -- or more.  Yesterday I found that I needed to turn off  
autoresizing on the ^content view^ of an NSBox which I was laying out  
manually.


... however, obviously, my items don't get re-sized... which isn't  
really how I need it to behave...


Haven't taken the time to digest your whole problem, but it looks like  
you may want to autoresize vertically but not horizontally or vice  
versa.  I recommend logging/setting your autoresize masks  
programatically, in -awakeFromNib maybe.


___

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


Writing kCFPreferencesAnyUser preferences by limited user

2009-02-13 Thread Alexander Shmelev

Hello,

I have Cocoa application, which have to store global settings, so I  
use CFPreferences...(..., kCFPreferencesAnyUser,  
kCFPreferencesCurrentHost).
Everything was ok while I launched application as admin user, but when  
I switched to limited user, settings changes were not saved.
I have found that I should use Security.framework. Then I wrote code  
below, it shows authentication dialog for limited user, but settings  
still not saving for limited user.

What do I do wrong? Could you advise me how to fix code?


extern OSStatus AcquireRight(const char *rightName)
{
OSStatus err;
static const AuthorizationFlags  kFlags =  
kAuthorizationFlagInteractionAllowed


| kAuthorizationFlagExtendRights;
AuthorizationItem   kActionRight = { rightName, 0, 0, 0 };
AuthorizationRights kRights  = { 1, &kActionRight };

assert(gAuthorization != NULL);

// Request the application-specific right.

err = AuthorizationCopyRights(
  
gAuthorization, // authorization
  &kRights, 
  // rights
  
kAuthorizationEmptyEnvironment,  // environment
  kFlags,   
  // flags
  NULL  
  // authorizedRights
  );

return err;
}


...

OSStatus err = AuthorizationCreate(NULL, NULL, 0, &gAuthorization);
err = AcquireRight("system.preferences");

	CFPreferencesSetValue(CFSTR("jpegCompressionFactor"),   
(CFNumberRef)jpegCompression, CFSTR(MFSDomainName),

  kCFPreferencesAnyUser, 
kCFPreferencesCurrentHost);
	CFPreferencesSynchronize(CFSTR(MFSDomainName), kCFPreferencesAnyUser,  
kCFPreferencesCurrentHost);

...

---
BR, Alexander

___

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: newbie question on creating .png files

2009-02-13 Thread Steven Spencer
To get a NSBitmapImageRep from a NSImage, have a look at the Reducer sample 
code at location :

http://developer.apple.com/samplecode/Reducer/listing16.html

file : ImageReducer.m
routine : BitmapImageRepFromNSImage

at the end of the file.

- Steve



>
>
>On 12.02.2009, at 17:14, Jean-Daniel Dupas wrote:
>
>>
>> Unfortunately, I don't think you can save an NSImage as a PNG (it  
>> only supports the TIFFRepresentation method).
>>
>
>You can create a new NSBitmapImageRep using the TIFFRepresentation and  
>use representationUsingType:properties:
>to get the PNG-data:
>
> NSData* TIFFData = [img TIFFRepresentation];
> NSBitmapImageRep* bitmapImageRep = [NSBitmapImageRep  
>imageRepWithData:TIFFData];
> NSData* PNGData = [bitmapImageRep  
>representationUsingType:NSPNGFileType properties:nil];
> [PNGData writeToFile: @"JAN01.png" atomically: YES];
>
>HTH,
>
>felix
>
>
>-- 
___

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: alloc/release confusion

2009-02-13 Thread Bryan Henry
When you call -show, the UIAlertView is retained elsewhere (somewhere  
in SpringBoard's internals).


It does look a bit odd, and understandably so, but the -release is  
correct there because you still want to relinquish your ownership of  
the object...the ownership you took when you sent the -alloc message.  
That release doesn't actually deallocate the object because it was  
retained by some part of -show's implementation.


Bryan

Sent from my iPhone

On Feb 13, 2009, at 6:02 PM, Boon Chew  wrote:


Hi all,

I am very new to Cocoa programming (but have programmed in C/C++  
before) and there is one thing I don't understand with alloc and  
release.  Sometimes I see code that alloc an object and release it  
within the same method, even though it's clear that the object is  
still live and well.


For example:

-(IBAction)onButtonPressed
{
 UIAlertView *alert = [[UIAlertView alloc] initWithTitle...];
 [alert show];
 [alert release];
}

Why is the code decrementing the ref count even though the alert  
window is still up?


Also, how do you know when you are decrementing ref count too soon?  
How do you know which object method you call might increase the ref  
count of the object in question?


Thanks!

- boon







___

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/bryanhenry%40mac.com

This email sent to bryanhe...@mac.com

___

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 inside an NSSplitView?

2009-02-13 Thread Jean-Nicolas Jolivet

Thanks for the tip!!!

I played with the auto-resize settings (on all the views involved,  
which means..quite a bunch) and I finally found a combo that appears  
to be much much better...


Still a bit of stuttering/drawing glitches but nothing close to how  
bad it was before...



On 13-Feb-09, at 6:52 PM, Jerry Krinock wrote:



On 2009 Feb 13, at 13:34, Jean-Nicolas Jolivet wrote:

If I disable the item's re-sizing, the behavior is less apparent...  
it's still a little odd (sometimes the items are attached to the  
right side of the collection viewthen all of a sudden they go  
back to their original place etc..)  but it's definitely not as bad


Yes, whenever I see stuff jumping around like in your movie I start  
sniffing around for an evil autoresize setting, and almost always  
find one -- or more.  Yesterday I found that I needed to turn off  
autoresizing on the ^content view^ of an NSBox which I was laying  
out manually.


... however, obviously, my items don't get re-sized... which isn't  
really how I need it to behave...


Haven't taken the time to digest your whole problem, but it looks  
like you may want to autoresize vertically but not horizontally or  
vice versa.  I recommend logging/setting your autoresize masks  
programatically, in -awakeFromNib maybe.


___

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/silvertab%40videotron.ca

This email sent to silver...@videotron.ca


Jean-Nicolas Jolivet
silver...@videotron.ca
http://www.silverscripting.com

___

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: Programatically Uncheck "Change Picture" In Desktop Settings?

2009-02-13 Thread Chunk 1978
when running my apple script i get this error:

-=-=-=-
System Events got an error: Access for assistive devices is disabled.
-=-=-=-

so if i goto system prefs and check "Enable access for assistive
devices", then running the script i get this error:

-=-=-=-
System Events got an error: Can't get application process "System Preferences".
-=-=-=-

here's my script:

-=-=-=-
tell application "System Events"
tell application process "System Preferences"
if value of checkbox "Change picture:" of group 1 of tab group 
1 of
window "Desktop & Screen Saver" is 1 then
click checkbox "Change picture:" of group 1 of tab 
group 1 of
window "Desktop & Screen Saver"
end if
end tell
end tell
-=-=-=-


On Fri, Feb 13, 2009 at 5:34 PM, Ken Thomases  wrote:
> On Feb 13, 2009, at 3:30 PM, Chunk 1978 wrote:
>
>> is this possible?  it seems that programatically changing
>> com.apple.desktop.plist (Background > Default > Change) from
>> TimeInterval to Never will not override the settings in System
>> Preferences.  i though applescript could be an option but it seems
>> that using an applescript to accomplish this would have to open the
>> system preferences window.  it's only ideal if it's done as a
>> background process.
>
> You want to target System Events rather than System Preferences with your
> AppleScript.
>
> Contrary to I. Savant, I don't think going through NSUserDefaults or
> CFPreferences will work.  It still won't inform the necessary processes of
> the change in an active manner.
>
> Take a look at the LoginItemsAE sample code.
>  
>
> Obviously, you're not working with Login Items, but it demonstrates the
> technique of sending Apple Events to System Events.  Also, modifying the
> user's login items has some conceptual similarities to what you're trying to
> do.  You might be tempted to modify the list of login items by manipulating
> the relevant .plist file, or by using NSUserDefaults or CFPreferences, but
> that's not appropriate.  The main failing is that, if the user actually has
> the Login Items tab of the Accounts pane of System Preferences open, changes
> you make to the preferences won't be reflected there.  Furthermore, the pane
> may at any time re-save what it thinks is the current state of the list,
> obliterating the change you attempted to make behind its back.
>
> (Ironically, the new shiny way to manipulate Login Items is the
> LSSharedFileList API, not this sample code.  That API is currently only
> documented in .)
>
> Cheers,
> Ken
>
>
___

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: Writing kCFPreferencesAnyUser preferences by limited user

2009-02-13 Thread Nick Zitzmann


On Feb 13, 2009, at 4:54 PM, Alexander Shmelev wrote:

I have found that I should use Security.framework. Then I wrote code  
below, it shows authentication dialog for limited user, but settings  
still not saving for limited user.

What do I do wrong? Could you advise me how to fix code?



You can't elevate an existing task's privileges, so you'll have to do  
whatever you need to do in a helper app invoked with  
AuthorizationExecuteWithPrivileges(). See the  
BetterAuthorizationSample sample code on ADC for details.


Nick Zitzmann




___

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: alloc/release confusion

2009-02-13 Thread Boon Chew

Thanks Bryan.

How do I go about knowing whether a method like show would do the retain? The 
reference doc doesn't say it.  Also, what if it doesn't? Would a premature 
release dealloc an object that's still alive (such as a dialog), causing the 
system to crash when the memory is overwritten by another object later?

Is there a way in Cocoa to find out the reference count of an object (for 
debugging purposes)?

- boon

--- On Fri, 2/13/09, Bryan Henry  wrote:

> From: Bryan Henry 
> Subject: Re: alloc/release confusion
> To: "Boon Chew" 
> Cc: "cocoa-dev@lists.apple.com" 
> Date: Friday, February 13, 2009, 4:02 PM
> When you call -show, the UIAlertView is retained elsewhere
> (somewhere in SpringBoard's internals).
> 
> It does look a bit odd, and understandably so, but the
> -release is correct there because you still want to
> relinquish your ownership of the object...the ownership you
> took when you sent the -alloc message. That release
> doesn't actually deallocate the object because it was
> retained by some part of -show's implementation.
> 
> Bryan
> 
> Sent from my iPhone
> 
> On Feb 13, 2009, at 6:02 PM, Boon Chew
>  wrote:
> 
> > Hi all,
> > 
> > I am very new to Cocoa programming (but have
> programmed in C/C++ before) and there is one thing I
> don't understand with alloc and release.  Sometimes I
> see code that alloc an object and release it within the same
> method, even though it's clear that the object is still
> live and well.
> > 
> > For example:
> > 
> > -(IBAction)onButtonPressed
> > {
> >  UIAlertView *alert = [[UIAlertView alloc]
> initWithTitle...];
> >  [alert show];
> >  [alert release];
> > }
> > 
> > Why is the code decrementing the ref count even though
> the alert window is still up?
> > 
> > Also, how do you know when you are decrementing ref
> count too soon? How do you know which object method you call
> might increase the ref count of the object in question?
> > 
> > Thanks!
> > 
> > - boon
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > ___
> > 
> > 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/bryanhenry%40mac.com
> > 
> > This email sent to bryanhe...@mac.com


  
___

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: Converting a CMYK NSImage to RGB

2009-02-13 Thread Ron Aldrich

Hi Ken,

Actually, the -[NSImage lockFocus]/-[NSImage unlockFocus] were added  
to deal with a multi-thread problem that was deadlocking things.  If a  
background thread updated screen state while I was creating the RGB  
image representation, I would later see a message in the console log  
reading "unlockFocus called too many time.", and threads would start  
deadlocking.


I changed things  around a bit, and am now calling lockFocus on  
rgbImage instead - simply to avoid the multi-thread issue.  It seems  
to be working.


Thanks for your time,

Ron Aldrich
Software Architects, Inc.

On Feb 13, 2009, at 1:41 PM, Ken Ferry wrote:


Hi Ron,

It was the -[NSImage lockFocus]/-[NSImage unlockFocus] that did it.   
You should just take them out, they weren't relevant to what you  
were trying to do.


-[NSImage lockFocus] sets the receiver up as a drawing  
_destination_.  You aren't trying to draw into the image here,  
you're trying to draw _from_ it.


lockFocus will
(1) Create a buffer.
(2) Make the buffer the current drawing graphics context, so that  
methods like NSRectFill are directed to the buffer.

(3) Draw the existing contents of the image into the new buffer.

unlockFocus will
(4) pop the current graphics context back to whatever it was before  
lockFocus was called.
(5) take the contents of the buffer and make them the new contents  
of the image.


In particular, lockFocus/unlockFocus is necessarily destructive.   
The old image representations are discarded, replaced with a new one.


-Ken

On Thu, Feb 12, 2009 at 5:52 PM, Ron Aldrich  wrote:
Folks,

I'm having an issue where CMYK images aren't being recognized by my  
quartz compositions, so I need to convert them to RGB for display.


I've written a routine to do it, but its causing problems.

 NSImageRep* theImageRep = [inputImage bestRepresentationForDevice:  
[NSDictionary dictionaryWithObject: NSDeviceRGBColorSpace
  forKey 
: NSDeviceColorSpaceName]];


 NSString* theColorSpace = [theImageRep colorSpaceName];

 if ([theColorSpace isEqualToString: NSDeviceCMYKColorSpace])
 {
   NSBitmapImageRep* theRGBImageRep = [[[NSBitmapImageRep alloc]  
initWithBitmapDataPlanes: NULL
   pixelsWide 
: [theImageRep pixelsWide]
   pixelsHigh 
: [theImageRep pixelsHigh]
bitsPerSample 
: 8
  samplesPerPixel 
: 4
 hasAlpha 
: YES
 isPlanar 
: NO
   colorSpaceName 
: NSDeviceRGBColorSpace
  bytesPerRow 
: 0
 bitsPerPixel 
: 0] autorelease];


   [inputImage lockFocus];

   NSGraphicsContext* theContext = [NSGraphicsContext  
graphicsContextWithBitmapImageRep: theRGBImageRep];

   [NSGraphicsContext saveGraphicsState];
   [NSGraphicsContext setCurrentContext: theContext];

   NSRect theBoundsRect = NSMakeRect(0.0, 0.0, [theRGBImageRep  
pixelsWide], [theRGBImageRep pixelsHigh]);


   [[NSColor clearColor] set];
   NSRectFill(theBoundsRect);

   [theImageRep drawInRect: theBoundsRect];

   [NSGraphicsContext restoreGraphicsState];

   [inputImage unlockFocus];

   ASSIGNOBJECT(rgbImage, [[[NSImage alloc] initWithSize:  
[theImageRep size]] autorelease]);


   [rgbImage addRepresentation: theRGBImageRep];
 }
 else
 {
   ASSIGNOBJECT(rgbImage, inputImage);
 }

The resulting image is correct, but somewhere along the line, my  
original image (inputImage) is being modified - the CMYK  
representation is being removed, and replaced with a downsampled RGB  
representation.  The goal here was to leave inputImage unmodified,  
so that when it is finally sent to the printer, the CMYK  
representation would be used.


inputImage before creating the RGB version.

NSImage 0x12313dd0 Size={340.08, 340.08} Reps=(
   NSBitmapImageRep 0xd8201c0 Size={340.08, 340.08}  
ColorSpace=NSDeviceCMYKColorSpace BPS=8 BPP=32 Pixels=1417x1417  
Alpha=NO Planar=NO Format=0

)

inputImage after creating the RGB version.

NSImage 0x12313dd0 Size={340.08, 340.08} Reps=(
   NSCachedImageRep 0xd824530 Size={340, 340}  
ColorSpace=NSCalibratedRGBColorSpace BPS=8 Pixels=340x340 Alpha=NO

)

Clearly, I'm doing something wrong.  I added calls to [inputImage  
lockFocus] and [inputImage unlockFocus] in order to resolve a multi- 
thread problem, but that seems to have caused this problem.


So, what's the best way for me to convert a

Re: alloc/release confusion

2009-02-13 Thread Sherm Pendley
On Fri, Feb 13, 2009 at 7:55 PM, Boon Chew  wrote:

>
> How do I go about knowing whether a method like show would do the retain?


You don't *need* to know whether other objects retain their arguments. They
follow the same rules your own objects follow, so if they do retain it, it's
their responsibility to release it when they're done with it.

The reference doc doesn't say it.  Also, what if it doesn't?


It doesn't matter if it does or doesn't - your own responsibilities are
exactly the same either way.


> Is there a way in Cocoa to find out the reference count of an object (for
> debugging purposes)?


If you're looking at he reference count for debugging purposes, you're doing
it wrong. That path leads to further confusion, not fixed bugs.

You really need to read this: <
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html
>

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
___

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


Cursor color in NSTextField?

2009-02-13 Thread Jean-Nicolas Jolivet
I was wondering if it was possible to change the cursor color in an  
NSTextField?


I see that NSTextView has setInsertionPointColor:

However, NSTextField doesn't and even if I access the editor (using  
the "currentEditor" method)  NSText also has no setInsertionPointColor  
method...




Jean-Nicolas Jolivet
silver...@videotron.ca
http://www.silverscripting.com

___

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 handle clicks on NSOutlineView

2009-02-13 Thread Jacob Rhoden

Hi guys,

I am trying to do an action when an item in an NSOutlineView is clicked. 
How do I work out which item was actually clicked on? Ive tried all 
sorts of things and nothing seems to work.  (Google or Cocoa programmng 
for mac os x 3rd edition are not that helpful on this!)


-(void)awakeFromNib {
[outline setAction:@selector(loadMemberList:)];
}

-(IBAction)loadMemberList:(id)sender {
if(ldap.connected) {
NSLog(@"Load members");
NSLog(@" site %@ ",[[outline selectedCell] name]);
}
}

Thanks,
Jacob

--

Jacob Rhoden  http://jacobrhoden.com

___

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: Writing kCFPreferencesAnyUser preferences by limited user

2009-02-13 Thread Jerry Krinock


On 2009 Feb 13, at 16:54, Nick Zitzmann wrote:



On Feb 13, 2009, at 4:54 PM, Alexander Shmelev wrote:

I have found that I should use Security.framework. Then I wrote  
code below, it shows authentication dialog for limited user, but  
settings still not saving for limited user.

What do I do wrong? Could you advise me how to fix code?



You can't elevate an existing task's privileges, so you'll have to  
do whatever you need to do in a helper app invoked with  
AuthorizationExecuteWithPrivileges(). See the  
BetterAuthorizationSample sample code on ADC for details.


Nick is correct about BetterAuthorizationSample.

While scratching my head over BetterAuthorizationSample during a week  
or so last year, I wrote a wrapper for it which you might find useful  
or at least enlightening


http://www.sheepsystems.com/sourceCode/authTasksCocoa.html

Read the readme.rtf in the project.  One of the "application cases"  
included in the demo is writing to kCFPreferencesAnyUser, since I  
needed to do that too.

___

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 / CFRunLoop

2009-02-13 Thread Alexander Cohen




Le 13 févr. 09 à 21:54, Alexander Cohen a écrit :


Hi,

Not sure if this is the right place to ask since my question is  
about CFRunLoop, not Cocoa but CoreFoundation. If not, please  
direct me to the right list.


I'm looking for a way to get the main CFRunLoop on tiger. On  
leopard, there is a simple call for it but i'm stuck with tiger for  
now. And while i'm at it, i'd like to do something like [obj  
performSelectorOnMainThread...] in CoreFoundation using CFRunLoops.  
I'm sure it's possible but i'm not sure where to start.


thx


To get the main runloop, you can save it in a global variable at  
program startup, and return it when requested.


There is no easy way to mimic performSelectorOnMainThread: as there  
is no easy way to serialize a function call (unlike in Cocoa where  
you can easily serialize a method call using NSInvocation to send it  
on the main thread).


To do inter-thread messaging using only low-level frameworks, you  
are stuck with the traditional facilities (socket, pipes, etc.)


Just by curiosity, what prevent you to use the Foundation framework ?


I'm in some C++ code and cannot use Foundation, only CF. I did find a  
solution though. The solution is to create a RunLoopSource and pass it  
an object ( C++ ) that knows what function to call in it's context.  
When the source is signaled, i'm in the main thread ( cause i added it  
to the main thread's RunLoop ), works like a charm. Is this something  
that is good or am I doing this all wonrg? :)


thx
AC___

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 handle clicks on NSOutlineView

2009-02-13 Thread Nick Zitzmann


On Feb 13, 2009, at 6:22 PM, Jacob Rhoden wrote:

I am trying to do an action when an item in an NSOutlineView is  
clicked. How do I work out which item was actually clicked on?



Did you try -clickedRow?

Nick Zitzmann




___

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: Programatically Uncheck "Change Picture" In Desktop Settings?

2009-02-13 Thread Ken Thomases

On Feb 13, 2009, at 6:25 PM, Chunk 1978 wrote:


when running my apple script i get this error:

-=-=-=-
System Events got an error: Access for assistive devices is disabled.
-=-=-=-

so if i goto system prefs and check "Enable access for assistive
devices", then running the script i get this error:

-=-=-=-
System Events got an error: Can't get application process "System  
Preferences".

-=-=-=-

here's my script:

-=-=-=-
tell application "System Events"
tell application process "System Preferences"
if value of checkbox "Change picture:" of group 1 of tab group 
1 of
window "Desktop & Screen Saver" is 1 then
click checkbox "Change picture:" of group 1 of tab 
group 1 of
window "Desktop & Screen Saver"
end if
end tell
end tell
-=-=-=-


You're trying to do things the indirect, and thus hard, way.  First,  
you're trying to do GUI scripting by poking directly at controls  
(checkboxes, groups, tabs, windows, etc.).  That's inherently fragile  
and requires that access for assistive devices be enabled (as you've  
seen).  By the way, wrapping a tell block that's addressing System  
Preferences inside of a tell block to System Events doesn't really  
help.  The reason I told you to script System Events was that you  
shouldn't be scripting System Preferences.


Using Script Editor's Library, open the dictionary for System Events.   
Look at the Desktop Suite.  There's a class "desktop" which has a  
"picture rotation" property (as well as others you may find useful).   
From the containment hierarchy view, we see that the application  
object contains "desktops" and has a "current desktop" property of  
this class.  So:


tell application "System Events"
set the picture rotation of current desktop to 0
end tell

Or, because there can be multiple desktops:

tell application "System Events"
repeat with theDesktop in desktops
set picture rotation of theDesktop to 0
end repeat
end tell

Since your original purpose was to set the desktop background picture,  
you may wish to 'set picture of theDesktop to POSIX file "/path/to/my/ 
picture"' in the script, too.  (You may specify the file in some other  
way, of course.)


Regards,
Ken

___

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: Cursor color in NSTextField?

2009-02-13 Thread Jean-Nicolas Jolivet
Hmmm to avoid any confusion, what I want to change is the *caret*  
color (the insertion point...) not the mouse cursor! I realized  
later how it might have sound confusing...



On 13-Feb-09, at 8:16 PM, Jean-Nicolas Jolivet wrote:

I was wondering if it was possible to change the cursor color in an  
NSTextField?


I see that NSTextView has setInsertionPointColor:

However, NSTextField doesn't and even if I access the editor (using  
the "currentEditor" method)  NSText also has no  
setInsertionPointColor method...




Jean-Nicolas Jolivet
silver...@videotron.ca
http://www.silverscripting.com

___

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/silvertab%40videotron.ca

This email sent to silver...@videotron.ca


Jean-Nicolas Jolivet
silver...@videotron.ca
http://www.silverscripting.com

___

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


Line spacing in NSTextView

2009-02-13 Thread Slava Pestov
Hi all,

Can someone enlighten me, how does NSTextView compute line spacing?

When I display a piece of text in stickies, with Helvetica 12 (or any
other font, really), and the same piece of text in my application,
stickies adds another 2 pixels of spacing between every line, and the
result looks more legible. Otherwise the font rendering is identical.
I'm using Core Text to render each line individually, and I presume
Stickies is using an NSTextView. I'm computing line height by adding
the ascent, descent and leading, but for Helvetica 12 at least the
leading is zero.

Slava
___

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: Programatically Uncheck "Change Picture" In Desktop Settings?

2009-02-13 Thread Chunk 1978
thanks a million ken!... this helps me on so many levels :)

On Fri, Feb 13, 2009 at 9:02 PM, Ken Thomases  wrote:
> On Feb 13, 2009, at 6:25 PM, Chunk 1978 wrote:
>
>> when running my apple script i get this error:
>>
>> -=-=-=-
>> System Events got an error: Access for assistive devices is disabled.
>> -=-=-=-
>>
>> so if i goto system prefs and check "Enable access for assistive
>> devices", then running the script i get this error:
>>
>> -=-=-=-
>> System Events got an error: Can't get application process "System
>> Preferences".
>> -=-=-=-
>>
>> here's my script:
>>
>> -=-=-=-
>> tell application "System Events"
>>tell application process "System Preferences"
>>if value of checkbox "Change picture:" of group 1 of tab
>> group 1 of
>> window "Desktop & Screen Saver" is 1 then
>>click checkbox "Change picture:" of group 1 of tab
>> group 1 of
>> window "Desktop & Screen Saver"
>>end if
>>end tell
>> end tell
>> -=-=-=-
>
> You're trying to do things the indirect, and thus hard, way.  First, you're
> trying to do GUI scripting by poking directly at controls (checkboxes,
> groups, tabs, windows, etc.).  That's inherently fragile and requires that
> access for assistive devices be enabled (as you've seen).  By the way,
> wrapping a tell block that's addressing System Preferences inside of a tell
> block to System Events doesn't really help.  The reason I told you to script
> System Events was that you shouldn't be scripting System Preferences.
>
> Using Script Editor's Library, open the dictionary for System Events.  Look
> at the Desktop Suite.  There's a class "desktop" which has a "picture
> rotation" property (as well as others you may find useful).  From the
> containment hierarchy view, we see that the application object contains
> "desktops" and has a "current desktop" property of this class.  So:
>
> tell application "System Events"
>set the picture rotation of current desktop to 0
> end tell
>
> Or, because there can be multiple desktops:
>
> tell application "System Events"
>repeat with theDesktop in desktops
>set picture rotation of theDesktop to 0
>end repeat
> end tell
>
> Since your original purpose was to set the desktop background picture, you
> may wish to 'set picture of theDesktop to POSIX file "/path/to/my/picture"'
> in the script, too.  (You may specify the file in some other way, of
> course.)
>
> Regards,
> Ken
>
>
___

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


iTableView and subclassing NSTableView

2009-02-13 Thread Stephen Zyszkiewicz
I am trying to use Matt Gemmell's iTableView (Source List and Colored  
Checkboxes):

http://mattgemmell.com/source

It includes a SourceListTableView subclass of NSTableView.

The problem is that the checkboxes within the table are not being  
unchecked/checked.


Do I need to implement a keydown event in SourceListTableView? If so,  
how do I do this so that the proper checkboxes are checked/unchecked?



Thank you!
Steve
___

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: Images In Dock Menu?

2009-02-13 Thread Peter Ammon


On Feb 13, 2009, at 3:27 PM, Chunk 1978 wrote:


i have a NSMenu that i use as both a right-click menu and the dock
menu.  The images i use for some of the menu items will appear in the
right-click menu, but they do not show up in the dock menu.

i've connected the the File's Owner dockMenu to the NSMenu in IB so to
add the menu to the app's dock menu.  i've searched for an answer in
the archives, but it seems that this has been a "known issue" since
2003?


The Dock menu is more limited than a general menu, because it has to  
be sent to the Dock process, where it's shown.  Images are not  
supported in it.


-Peter


___

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 handle clicks on NSOutlineView

2009-02-13 Thread Graham Cox


On 14 Feb 2009, at 12:22 pm, Jacob Rhoden wrote:

I am trying to do an action when an item in an NSOutlineView is  
clicked. How do I work out which item was actually clicked on? Ive  
tried all sorts of things and nothing seems to work.  (Google or  
Cocoa programmng for mac os x 3rd edition are not that helpful on  
this!)



You need to supply a delegate to the outline view and implement the  
delegate method:


-outlineViewSelectionDidChange:

hth,

--Graham


___

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: Line spacing in NSTextView

2009-02-13 Thread Graham Cox


On 14 Feb 2009, at 1:15 pm, Slava Pestov wrote:


Hi all,

Can someone enlighten me, how does NSTextView compute line spacing?

When I display a piece of text in stickies, with Helvetica 12 (or any
other font, really), and the same piece of text in my application,
stickies adds another 2 pixels of spacing between every line, and the
result looks more legible. Otherwise the font rendering is identical.
I'm using Core Text to render each line individually, and I presume
Stickies is using an NSTextView. I'm computing line height by adding
the ascent, descent and leading, but for Helvetica 12 at least the
leading is zero.


Line spacing (or to be more precise, leading) is an attribute of the  
paragraph style. This is added to the lineheight of the font as you  
have calculated.


--Graham


___

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: Programatically Uncheck "Change Picture" In Desktop Settings?

2009-02-13 Thread I. Savant

On Feb 13, 2009, at 5:34 PM, Ken Thomases wrote:

Contrary to I. Savant, I don't think going through NSUserDefaults or  
CFPreferences will work.  It still won't inform the necessary  
processes of the change in an active manner.



  You're likely right - the process in question would have to be  
listening for changes to its preferences, which it's probably not.  
However, my point was to illustrate that merely changing a plist is  
the absolute least likely to trigger the desired change in the active  
application / system process using that plist as a persistent store  
for the state of its preferences. Let alone the 'tradition' of  
unceremoniously killing a process to force it to load that changed  
plist ...


  In any case, even if you're sure you fully understand what  
preference keypaths are used for a given function (ie legacy  
preferences that have been migrated or simply deprecated), you still  
need to worry about your direct-file-manipulations clobbering (or  
being clobbered by) a flush from the preferences system in the given  
domain. Wanna' take that chance with your user's system that you know  
all the pros and cons? :-)


  It's for this reason that the 'traditional' way to add a shortcut  
to the Dock is considered dirty and wrong (modifying its plist and  
forcibly killing the process to force it to reload its preferences  
when it respawns), which is only necessary because of a lack of public  
API.


  Of course in this case, it appears AppleScript will do the job (I  
wouldn't know - I've never attempted what the OP is attempting).  
That's a considerably better option. :-)


--
I.S.

___

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


Can anyone suggest a way to do this?

2009-02-13 Thread Graham Cox
This may be more appropriate for the Quartz mailing list, which I'm  
not on, so I'll ask here first...


When stroking a path, I can clip to the inside or the outside of the  
path to get a stroke inside or outside of the path's edge. But if the  
path is open-ended, this doesn't work. Instead what I need is clipping  
to the "left" or "right" of a path, not to the "inside" or "outside".


My question is, can anyone think of any way in which this might be  
accomplished?



--Graham


___

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: Programatically Uncheck "Change Picture" In Desktop Settings?

2009-02-13 Thread Ken Thomases

On Feb 13, 2009, at 9:36 PM, I. Savant wrote:


On Feb 13, 2009, at 5:34 PM, Ken Thomases wrote:

Contrary to I. Savant, I don't think going through NSUserDefaults  
or CFPreferences will work.  It still won't inform the necessary  
processes of the change in an active manner.


  You're likely right - the process in question would have to be  
listening for changes to its preferences, which it's probably not.


I don't even think there's a supported way for it to listen for  
changes.  CFPreferences and NSUserDefaults can synchronize with  
externally-made changes, but in order to detect changes you'd have to  
make a record of the pre-synchronize prefs, synchronize, and then  
compare the new state to the old.  Maybe NSUserDefaultsController does  
this -- I don't know, but I doubt it.



However, my point was to illustrate that merely changing a plist is  
the absolute least likely to trigger the desired change in the  
active application / system process using that plist as a persistent  
store for the state of its preferences. [...]


Sure.  Agreed.

Cheers,
Ken

___

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: Programatically Uncheck "Change Picture" In Desktop Settings?

2009-02-13 Thread I. Savant

On Feb 13, 2009, at 10:53 PM, Ken Thomases wrote:

I don't even think there's a supported way for it to listen for  
changes.


NSUserDefaultsDidChangeNotification?

--
I.S.




___

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 / CFRunLoop

2009-02-13 Thread Adam R. Maxwell


On Feb 13, 2009, at 12:54 PM, Alexander Cohen wrote:

I'm looking for a way to get the main CFRunLoop on tiger. On  
leopard, there is a simple call for it but i'm stuck with tiger for  
now. And while i'm at it, i'd like to do something like [obj  
performSelectorOnMainThread...] in CoreFoundation using CFRunLoops.  
I'm sure it's possible but i'm not sure where to start.


For what it's worth, CFRunLoopGetMain() is available in Tiger and  
earlier, according to the header:


CF_EXPORT CFRunLoopRef CFRunLoopGetMain(void)  
AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER;


I filed a documentation bug on this a year ago, but it's still open (rdar://problem/5773731 
).





smime.p7s
Description: S/MIME cryptographic signature
___

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: Programatically Uncheck "Change Picture" In Desktop Settings?

2009-02-13 Thread Ken Thomases

On Feb 13, 2009, at 10:04 PM, I. Savant wrote:


On Feb 13, 2009, at 10:53 PM, Ken Thomases wrote:

I don't even think there's a supported way for it to listen for  
changes.


NSUserDefaultsDidChangeNotification?


I believe that's only for internally-generated changes.  There are a  
couple of methods of NSUserDefaults which are explicitly documented as  
posting that notification, and no mention of other circumstances under  
which it would be posted.


But I could very well be wrong.

Cheers,
Ken

___

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 handle clicks on NSOutlineView

2009-02-13 Thread Jacob Rhoden

On 14/2/09 3:39 PM, Graham Cox wrote:

On 14 Feb 2009, at 12:22 pm, Jacob Rhoden wrote:
I am trying to do an action when an item in an NSOutlineView is 
clicked. How do I work out which item was actually clicked on? Ive 
tried all sorts of things and nothing seems to work.  (Google or 
Cocoa programmng for mac os x 3rd edition are not that helpful on 
this!)



For an outline view you can also use -itemAtRow: to directly get the 
object to which it refers.


Thansks! That was the method I was looking for, I didnt think to look 
for methods there!


--

Jacob Rhoden  http://jacobrhoden.com

___

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: Images In Dock Menu?

2009-02-13 Thread Gregory Weston

Chunk 1978 wrote:


i have a NSMenu that i use as both a right-click menu and the dock
menu.  The images i use for some of the menu items will appear in the
right-click menu, but they do not show up in the dock menu.

i've connected the the File's Owner dockMenu to the NSMenu in IB so to
add the menu to the app's dock menu.  i've searched for an answer in
the archives, but it seems that this has been a "known issue" since
2003?


The short answer is that the dock doesn't actually display the menu  
you hand it. It's just a convenient device for specifying your own  
menu content and then conveying it to the other process. The down-side  
is that we lose some functionality. You've noticed the lack of images.  
Another loss is that building menus on the fly is impractical. It  
tries to resolve the whole structure up-front instead of as-needed  
(because, presumably, that *is* when it's needed) and if it takes too  
long it'll time out.

___

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: iTableView and subclassing NSTableView

2009-02-13 Thread Jerry Krinock


On 2009 Feb 13, at 18:31, Stephen Zyszkiewicz wrote:

The problem is that the checkboxes within the table are not being  
unchecked/checked.


Yes, that was rather surprising.  I pounded on my mouse a few times.

Do I need to implement a keydown event in SourceListTableView? If  
so, how do I do this so that the proper checkboxes are checked/ 
unchecked?


Step back.  There are two alternate ways to do this.

The first way, what you appear to be proposing, is to build a cell  
from scratch.  This can be done, and it may be the only way if you  
really want to have those colors inside the boxes.  Today, you'll be  
happy to see the box check and uncheck, but sooner or later you might  
end up re-implementing a whole lot of behavior (enable/disable,  
selected/unselected, NSCoding, bindings, etc.) that Apple has already  
provided in NSButtonCell.  I did this a couple years ago, making a  
radio button cell.  359 lines of code.  Let me know if you want it.   
To answer your question, it looks like I did not implement keyDown: or  
mouseDown:.


To appreciate the alternate way, understand what you're looking at  
there with Matt's checkbox is a SourceListImageCell, Matt's subclass  
of NSImageCell.  Notice that the other column is a SourceListTextCell,  
Matt's subclass of NSTextFieldCell.  The alternate way, following  
these two examples, would be to write your own SourceListButtonCell,  
as a subclass of NSButtonCell.  Although I'm not much of a drawing  
guru, I'd try and let super draw the checkbox in my  
drawInteriorWithFrame: implementation and then composite the colors,  
images, gradients whatever over or under it.  Although some  
compromises on the cosmetics may be necessary, you see Matt did this  
in only 50-60 lines of code.


It's kind of confusing that Matt used an image of a checkbox to  
demonstrate an image.  The demo would be easier to understand had he  
used a little apple or something.


___

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


Where to declare/initialise an NSOperationQueue

2009-02-13 Thread Jacob Rhoden

Hi Guys,

I have been starting to use NSOperationQueue. I have ended up with one 
put in each controller (ie see below), but now I have one in too many 
controllers. How does it work? Should I just have one global variable 
for the operation queue, or do multiple NSOperationQueue's "share" the 
same resources?


I guess I am looking for direction on how best to use it.

@interface WebsitesController : NSObject {
NSOperationQueue *operationQueue;
}

Thanks,
Jacob


Jacob Rhoden  http://jacobrhoden.com

___

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