Re: Unread count for items in Mail.app-styled NSOutlineView

2008-03-02 Thread Leonardo Cassarani

I'll look into it, thanks :)

On 2 Mar 2008, at 05:25, John Pannell wrote:


Hi Leonardo-

I implemented a counter that looked the same in a safari-like tabs  
implementation...


http://www.positivespinmedia.com/dev/PSMTabBarControl.html

Hope this helps!

John

___

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 [EMAIL PROTECTED]


Issue about cocoa Multi-document template

2008-03-02 Thread Scott.D.R

Hi everyone.
I want to start an application with the cocoa multi-document template.  
The default behavior of the application is when you launch it, a blank  
window is automatically open.


This behavior is not that I want. I thought the application should not  
open any window until users explicit open file command arrived.


So, is there any way to disable the application to open the window  
when launched? Thank you for any help. 
___


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 [EMAIL PROTECTED]


Re: Problems with ScriptingBridge and iTunes

2008-03-02 Thread has

Hannes Petri wrote:


I want to retrieve the path to the currently played file in iTunes. I
thought scripting bridge would be the perfect tool for this, however
i've run into some problem. I have this code:

iTunesApplication *iTunes = [[SBApplication alloc]
initWithBundleIdentifier:@"com.apple.iTunes"];
iTunesTrack *currentTrack = [iTunes currentTrack];

if ([currentTrack isKindOfClass:[iTunesFileTrack class]]) {


}

The problem is, that the class of the object returned is _always_
iTunesTrack, and not iTunesFileTrack, as i expect it to be.


Here's how you'd do it using objc-appscript :



// To generate iTunes glue: osaglue  -o ITGlue  -p IT  iTunes

#import 
#import "ITGlue/ITGlue.h"

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

	ITApplication *itunes = [[ITApplication alloc] initWithBundleID:  
@"com.apple.itunes"];

ITReference *track = [itunes currentTrack];

ITConstant *trackClass = [[[track class_] get] send];

if (trackClass == [ITConstant fileTrack]) {
ASAlias *trackFile = [[[track location] get] send];
NSLog(@"%@", trackFile);
}
[itunes release];
[pool drain];
return 0;
}

HTH

has
--
http://appscript.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 [EMAIL PROTECTED]


Re: Problems with ScriptingBridge and iTunes

2008-03-02 Thread Steven Degutis
Hannes,

I haven't heard of this ITApplication before, but for your specific
problem, I think it's clear why [currentTrack
isKindOfClass:[iTunesFileTrack class]] evaluates to true: in the
previous line, you defined it as such, like this:

iTunesTrack *currentTrack = [iTunes currentTrack];

So obviously it is an iTunesTrack!

Try this:

iTunesFileTrack *currentTrack = [iTunesFileTrack currentTrack];
NSLog(@"%@", [currentTrack location]);

Since iTunesFileTrack is a subclass of iTunesTrack, it should work,
giving you the info you need.

On Sun, Mar 2, 2008 at 6:05 AM, has <[EMAIL PROTECTED]> wrote:
> Hannes Petri wrote:
>
>  > I want to retrieve the path to the currently played file in iTunes. I
>  > thought scripting bridge would be the perfect tool for this, however
>  > i've run into some problem. I have this code:
>  >
>
> > iTunesApplication *iTunes = [[SBApplication alloc]
>  > initWithBundleIdentifier:@"com.apple.iTunes"];
>  > iTunesTrack *currentTrack = [iTunes currentTrack];
>  >
>  > if ([currentTrack isKindOfClass:[iTunesFileTrack class]]) {
>  >
>  >
>  > }
>  >
>  > The problem is, that the class of the object returned is _always_
>  > iTunesTrack, and not iTunesFileTrack, as i expect it to be.
>
>  Here's how you'd do it using objc-appscript 
>    >:
>
>
>  // To generate iTunes glue: osaglue  -o ITGlue  -p IT  iTunes
>
>  #import 
>  #import "ITGlue/ITGlue.h"
>
>  int main (int argc, const char * argv[]) {
> NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
>
> ITApplication *itunes = [[ITApplication alloc] initWithBundleID:
>  @"com.apple.itunes"];
> ITReference *track = [itunes currentTrack];
>
> ITConstant *trackClass = [[[track class_] get] send];
>
> if (trackClass == [ITConstant fileTrack]) {
> ASAlias *trackFile = [[[track location] get] send];
> NSLog(@"%@", trackFile);
> }
> [itunes release];
> [pool drain];
> return 0;
>  }
>
>  HTH
>
>  has
>  --
>  http://appscript.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/sephknows%40gmail.com
>
>  This email sent to [EMAIL PROTECTED]
>
___

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 [EMAIL PROTECTED]


Drawing only when NSOutlineView active?

2008-03-02 Thread Nicholas Riley
I'm attempting to draw a custom NSOutlineView row background only for  
selected rows of an active outline view; otherwise, the default  
drawing style is fine.  I started with the following:


- (void)highlightSelectionInClipRect:(NSRect)clipRect;
{
// the outline view is in a sheet, so the main window is always  
the window to which it's attached
if ([[self window] firstResponder] != self || ![[self window]  
isKeyWindow]) {

[super highlightSelectionInClipRect: clipRect];
return;
}
// fancy drawing here

This works fine except in two cases, when the test is inadequate and  
NSOutlineView draws an ordinary active row.


1. When another window, such as the Character Palette, or a status  
item gets keyboard focus.  To work around this, I can change the  
second check to:


[NSApp keyWindow] != [self window]

   which surprisingly returns a different result than ![[self window]  
isKeyWindow].


2. When a menu-window (e.g., the help menu's NSCarbonMenuWindow)  
becomes key.  In this case, the key window changes by either measure.


Is there a more effective way to discover whether I should draw the  
row background as active or not?


--
Nicholas Riley <[EMAIL PROTECTED]> | 

___

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 [EMAIL PROTECTED]


Re: Charting API?

2008-03-02 Thread Adhamh Findlay


On Mar 1, 2008, at 8:53 PM, David Adalsteinsson wrote:

I don't know exactly what the GraphKit API looks like, or which  
Apple applications actually use it.  The graphs don't quite look  
consistent between KeyNote, Shark, XRay and Activity monitor.



KeyNote uses its on classes, Shark, Chud, Activity monitor and I  
believe XRay use GraphKit.


Adhamh

___

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 [EMAIL PROTECTED]


Re: Reading word at mouse pointer w/o Universal Access

2008-03-02 Thread Ryan Homer
Well, if you are referring to the Services sub-menu that is  
automatically part of Cocoa applications' menus with the same name as  
the application (Eg: Mail -> Services, Safari -> Services, etc.), it  
seems to me that those services are only executed when invoked by the  
user. However, I want my application to be able to react to just the  
mouse pointer moving over a word.


On 28-Feb-08, at 9:27 PM, Andreas Monitzer wrote:


On Feb 29, 2008, at 02:33, Ryan Homer wrote:

Let me clarify that it doesn't seem to be the Dictionary  
application that's reading the word at the mouse pointer but rather  
the OS itself or some daemon, perhaps, when  Ctrl-Option-D is  
pressed. It might be the process called DictionaryPanel that seems  
to always be running.


Anyway, if anyone can point me to the appropriate functions/methods/ 
classes that might be involved in doing such a thing w/o the  
aforementioned techniques, please let me know.


Maybe you're looking for services? They're right in the application  
menu. They can do a lot of very nifty things, unfortunately they're  
very under-appreciated since they got moved one level down...


andy

___

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/hzc.lists%40gmail.com

This email sent to [EMAIL PROTECTED]


___

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 [EMAIL PROTECTED]


Re: Reading word at mouse pointer w/o Universal Access

2008-03-02 Thread Ryan Homer

Steve,

While I agree that the user should decide whether or not to allow the  
application to access another's text, to me, that's exactly what they  
are doing if they decide to use the application. It is going to be a  
dictionary-type application, so if the user installs it, s/he would be  
fully aware that its use would entail moving the mouse pointer over a  
word in another application. The application would be just about  
useless without that feature - so might as well delete it if you don't  
want that feature. It's just that I don't want to require that the  
user have to enable access for assistive devices. The first time I  
came across that, I was hesitant to enable that without knowing more  
about it and how many more services I would be keeping running all the  
time in the background, etc. This made me hesitant to even use the  
application that wanted to turn this on.


On 28-Feb-08, at 8:59 PM, Steve Christensen wrote:

I don't have specific knowledge but, yes, I would expect that the  
dictionary support is a trusted part of the OS, thus can be hooked  
into every application.


As far as I know, if you want to touch another application's UI, you  
have to go through accessibility. From the OS's point of view yours  
is just another application, so it seems reasonable that the user  
should decide whether or not to allow your application to see what's  
going on in another.


steve


On Feb 28, 2008, at 5:33 PM, Ryan Homer wrote:

Let me clarify that it doesn't seem to be the Dictionary  
application that's reading the word at the mouse pointer but rather  
the OS itself or some daemon, perhaps, when  Ctrl-Option-D is  
pressed. It might be the process called DictionaryPanel that seems  
to always be running.


Anyway, if anyone can point me to the appropriate functions/methods/ 
classes that might be involved in doing such a thing w/o the  
aforementioned techniques, please let me know.


On 28-Feb-08, at 8:27 PM, Ryan Homer wrote:

I've read this post (http://lists.apple.com/archives/accessibility-dev/2006/Aug/msg7.html 
) about using the accessibility options to read the text under the  
cursor. However, this requires that the user enable access for  
assistive devices in System Preferences. The application must  
therefore check for that. It also seems quite complicated; I don't  
want to have to deal with glyphs and the like - I only want the  
text under the cursor, full stop.


The Dictionary application is able to read a word under the cursor  
without enabling access for assistive devices.


Does anyone therefore know of an alternative way to do this?

Thanks in advance.


___

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/hzc.lists%40gmail.com

This email sent to [EMAIL PROTECTED]


___

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 [EMAIL PROTECTED]


how to forward the event into the document view of the clip view in a NSScrollView?

2008-03-02 Thread Scott . D . R

Hi everyone.

As the title mentioned, I found something odd when using the  
IKimageview with NSScrollView.
That is, At first, I directly drop a IKImageView into a window. And in  
my application, I set the source of the IKImageview. After the  
application run, I double-click the IKimageView and the image  
adjustment panel showed up. Everything is perfect.


Then I changed the style: I used a new window and placed a  
NSScrollview on it. Then I specify the document view which shows the  
"Custom view" in the NSScrollview to be a IKImageview. And in the  
application, I set the source the IKimageview. After the application  
run, the IKImageView shows the image. However, this time I double- 
click the IKimageview, the image adjustment panel didn't show up.


Can anyone tell me what's problem and how to solve it?
Thank you very much for any help.

Best regards.
___

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 [EMAIL PROTECTED]


Bypassing inter-cell navigation for NSButtonCell in NSOutlineView

2008-03-02 Thread Nicholas Riley
In Leopard, checkboxes in my NSOutlineViews get keyboard focus when I  
press Tab.  I don't want this to happen.


The AppKit release notes  state:



Tables now support inter-cell navigation as follows:

- Tabbing forward to a table focuses the entire table.
- Hitting Space will attempt to 'performClick:' on a NSButtonCell in  
the selected row, if there is only one instance in that row.


So far, so good.

- Tabbing again focuses the first "focusable" (1) cell, if there is  
one.


I don't want the NSButtonCell to ever get focus.

(1) A focusable cell is generally defined as [cell isEnabled] &&  
[cell isSelectable] in a table column that is editable. However,  
NSTextFieldCells also check if the row is selectable, and  
tableView:shouldEditTableColumn:row: returns YES (if implemented by  
the delegate). NSImageCells cannot be focused. NSButtonCells only  
check if the [cell isEnabled].


Disabling the NSButtonCell is not feasible; I want it to be operable.

I've tried a number of things that don't help, including:

1. [checkBoxColumn setEditable: NO];

2. [checkBoxCell setEditable: NO];

3. [checkBoxCell setRefusesFirstResponder: YES];

4. - (BOOL)outlineView:(NSOutlineView *)ov shouldTrackCell:(NSCell  
*)cell forTableColumn:(NSTableColumn *)column item:(id)item {

return NO;
}

5. - (BOOL)outlineView:(NSOutlineView *)outlineView  
shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item {

return NO;
}

6. - (BOOL)outlineView:(NSOutlineView *)outlineView  
shouldSelectTableColumn:(NSTableColumn *)tableColumn {

return NO;
}
(a long shot, certainly)

7. overriding keyDown: in the outline view to intercept Tab, which  
works fine, except...



- Back tabbing into a table will select the last focusable cell.


and I can't figure out how to stop that from happening.

Help?

--
Nicholas Riley <[EMAIL PROTECTED]> | 

___

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 [EMAIL PROTECTED]


Bypassing inter-cell navigation for NSButtonCell in NSOutlineView

2008-03-02 Thread Nicholas Riley
[Resending this as a later email I sent was delivered but this wasn't;  
sorry if you receive a duplicate copy.]


In Leopard, checkboxes in my NSOutlineViews get keyboard focus when I  
press Tab.  I don't want this to happen.


The AppKit release notes  state:



Tables now support inter-cell navigation as follows:

- Tabbing forward to a table focuses the entire table.
- Hitting Space will attempt to 'performClick:' on a NSButtonCell in  
the selected row, if there is only one instance in that row.


So far, so good.

- Tabbing again focuses the first "focusable" (1) cell, if there is  
one.


I don't want the NSButtonCell to ever get focus.

(1) A focusable cell is generally defined as [cell isEnabled] &&  
[cell isSelectable] in a table column that is editable. However,  
NSTextFieldCells also check if the row is selectable, and  
tableView:shouldEditTableColumn:row: returns YES (if implemented by  
the delegate). NSImageCells cannot be focused. NSButtonCells only  
check if the [cell isEnabled].


Disabling the NSButtonCell is not feasible; I want it to be operable.

I've tried a number of things that don't help, including:

1. [checkBoxColumn setEditable: NO];

2. [checkBoxCell setEditable: NO];

3. [checkBoxCell setRefusesFirstResponder: YES];

4. - (BOOL)outlineView:(NSOutlineView *)ov shouldTrackCell:(NSCell  
*)cell forTableColumn:(NSTableColumn *)column item:(id)item {

   return NO;
}

5. - (BOOL)outlineView:(NSOutlineView *)outlineView  
shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item {

   return NO;
}

6. - (BOOL)outlineView:(NSOutlineView *)outlineView  
shouldSelectTableColumn:(NSTableColumn *)tableColumn {

   return NO;
}
(a long shot, certainly)

7. overriding keyDown: in the outline view to intercept Tab, which  
works fine, except...



- Back tabbing into a table will select the last focusable cell.


and I can't figure out how to stop that from happening.

Help?

--
Nicholas Riley <[EMAIL PROTECTED]> | 

___

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 [EMAIL PROTECTED]


Re: Bypassing inter-cell navigation for NSButtonCell in NSOutlineView

2008-03-02 Thread Tommy Nordgren


On 2 mar 2008, at 13.29, Nicholas Riley wrote:


...sbip...


7. overriding keyDown: in the outline view to intercept Tab, which  
works fine, except...



- Back tabbing into a table will select the last focusable cell.


and I can't figure out how to stop that from happening.

Help?

--
Nicholas Riley <[EMAIL PROTECTED]> | 


	You probably need to modify your keyDown: method to intercept  
backtabs as well


--
What is a woman that you forsake her, and the hearth fire and the home  
acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the Dane  
women

Tommy Nordgren
[EMAIL PROTECTED]



___

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 [EMAIL PROTECTED]


Re: Issue about cocoa Multi-document template

2008-03-02 Thread Doug Knowles
You want to create an application delegate, and implement
applicationShouldOpenUntitledFile: in the delegate.
The application delegate can be an instance of any class.  I find it easiest
to create an instance of NSObject in Interface Builder, set its class to my
delegate class, and bind it the the application's delegate object,

Hope this helps.

Doug K;

On Sun, Mar 2, 2008 at 12:04 PM, Scott.D.R <[EMAIL PROTECTED]>
wrote:

> Hi everyone.
> I want to start an application with the cocoa multi-document template.
> The default behavior of the application is when you launch it, a blank
> window is automatically open.
>
> This behavior is not that I want. I thought the application should not
> open any window until users explicit open file command arrived.
>
> So, is there any way to disable the application to open the window
> when launched? Thank you for any help.
> ___
>
> 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/knowles.doug%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
___

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 [EMAIL PROTECTED]


Re: [NSOutlineView] How to know an item is expanded if its parent item is not?

2008-03-02 Thread Stéphane Sudre


On Mar 2, 2008, at 5:24 AM, Seth Willits wrote:


On Mar 1, 2008, at 6:01 PM, John Stiles wrote:

Unless Stephane plans on manually tracking the expanded items  
himself, I don't see how this answers his original question



That's what you have to do. I use these notifications to save which  
items are expanded as part of my documents' data. It's not  
particularly hard since at the very least, all you do is just keep  
an array of expanded items.


It might not be hard but it does not work.

Let's say I have the following hierarchy:

 Group --+-- Group 1
 |
 +-- Group 2
 |
 +-- Group 3


First, I don't implement notifications:

1. I disclose Group with the mouse
2. I disclose Group 1, Group 2, Group 3 with the mouse
3. I close Group
4. I disclose Group

=> Group 1, Group 2 and Group 3 are disclosed.

Then I implement outlineViewItemWillExpand: and  
outlineViewItemWillCollapse: notifications and see what happens when  
I follow the same procedure:


1. I disclose Group with the mouse

=> I receive a outlineViewItemWillExpand: notification for Group

2. I disclose Group 1, Group 2, Group 3 with the mouse

=> I receive outlineViewItemWillExpand: notifications for Group 1,  
Group 2 and Group 3


3. I close Group

=> I receive a outlineViewItemWillCollapse: notification for Group  
AND outlineViewItemWillCollapse: notifications for Group 1, Group 2  
and Group 3


4. I disclose Group

=> I receive a outlineViewItemWillExpand: notification for Group AND  
outlineViewItemWillExpand: notifications for Group 1, Group 2 and  
Group 3



So, apparently, it's just not that easy. And one thing to take into  
account in the array is the order in which items are listed because  
you need to have the correct order, otherwise the parent of an item  
may be processed after the item itself - which is not good -.


Maybe a solution could be to check if one of the parents for a group  
is collapsed or not before taking into account the notification...


Anyway, wouldn't it be much easier if the cache used by NSOutlineView  
(since it remembers which children were to be expanded) was accessible.




___

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 [EMAIL PROTECTED]


Re: Issue about cocoa Multi-document template

2008-03-02 Thread Gregory Weston

Scott.D.R wrote:


Hi everyone.
I want to start an application with the cocoa multi-document template.
The default behavior of the application is when you launch it, a blank
window is automatically open.

This behavior is not that I want. I thought the application should not
open any window until users explicit open file command arrived.


That's not the standard behavior of document-centric Mac OS X  
applications. The standard behavior is to present the user with a  
new, empty document when the app is launched by double-clicking the  
app icon or when it's activated by clicking the dock icon while no  
documents are open. So my first recommendation is to understand that  
and decided if you really need to deviate.



So, is there any way to disable the application to open the window
when launched? Thank you for any help.


In general in Cocoa, when you're looking to tweak the behavior of the  
application object, the place to look is the application's delegate.


One of NSApplication's delegate methods is  
applicationShouldOpenUntitledFile:. You'd want to override that to  
decide whether you want to open a new document and return the result  
of that decision.

___

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 [EMAIL PROTECTED]


Re: [NSOutlineView] How to know an item is expanded if its parent item is not?

2008-03-02 Thread Jonathan Dann


On 1 Mar 2008, at 23:02, Stéphane Sudre wrote:


There seems to be a missing method in NSOutlineView.

You can know an item is expanded only if its parent is expanded (so  
that the item itself is visible).


This is problematic if you want to cache the current list of  
expanded items. Instead of just iterating through the item hierarchy  
when needed, you would need to use the notifications sent when an  
item is about to be disclosed or closed.


This is a bit strange if you consider that NSOutlineView probably  
caches this information in _expandSet or _expandSetToExpandItemsInto  
so that it can remember to expand the children of an item if needed.


An I missing something and is there a way to know which items are  
expanded (either visible or not)?


For what it's worth, I haven't found a way to do this either, would be  
really great if this can be cracked.  I had to manually track all the  
NSOutlineViewItemDidExpand (and the Collapse) notifications.


Jon___

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 [EMAIL PROTECTED]


Re: Bypassing inter-cell navigation for NSButtonCell in NSOutlineView

2008-03-02 Thread Ricky Sharp


On Mar 2, 2008, at 6:29 AM, Nicholas Riley wrote:

In Leopard, checkboxes in my NSOutlineViews get keyboard focus when  
I press Tab.  I don't want this to happen.


The AppKit release notes  state:



Tables now support inter-cell navigation as follows:

- Tabbing forward to a table focuses the entire table.
- Hitting Space will attempt to 'performClick:' on a NSButtonCell  
in the selected row, if there is only one instance in that row.


So far, so good.

- Tabbing again focuses the first "focusable" (1) cell, if there is  
one.


I don't want the NSButtonCell to ever get focus.


It sounds like you have full keyboard access turned on.  And, what  
you're seeing is the correct behavior.


Be mindful of users that need to to interact with your application via  
accessibility.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
Instant Interactive(tm)   http://www.instantinteractive.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 [EMAIL PROTECTED]


Subclassing NSOutlineView causes failure of window to become main or key

2008-03-02 Thread Dennis Hartigan-O'Connor
I'm trying to use a subclass of NSOutlineView to allow merged columns, 
so that some cells can run over their bounds, using methods I read about at:


http://www.mactech.com/articles/mactech/Vol.18/18.11/1811TableTechniques/index.html

I have four instances of my custom subclass organized in an NSTabView.

I have the rather strange problem that my program runs, without 
crashing, and displays the tables with merged columns just as I desire. 
 However, the main window fails to become either main or key, so no 
input is accepted from the user.


I've done a lot of work trying to diagnose this problem and I have two 
key results:


1) Using NSOutlineViews, everything works fine.  In particular, by using 
windowDidBecomeKey and windowDidBecomeMain methods, I find that the main 
window becomes both key and main, and accepts user input, and everything 
works fine.


2) In an attempt to diagnose this problem, I created an "empty" subclass 
of NSOutlineView, which behaves exactly the same as NSOutlineView, 
because no methods are overwritten.  Here's the really strange part.  If 
I set ONE OR THREE of my four NSOutlineViews to the custom "empty 
class", everything works fine--the application runs just as if I were 
using four NSOutlineViews.  windowDidBecomeKey and windowDidBecomeMain 
are both called.  If I set TWO OR FOUR of my four NSOutlineViews to the 
custom "empty class", then the main window fails to become either main 
or key and no input is accepted.  windowDidBecomeKey and 
windowDidBecomeMain aren't called.


Believe it or not, I've actually been able to make everything work by 
adding a FIFTH instance of my custom subclass (providing merged columns) 
to the window and setting it to be hidden.  When I do this, my whole 
application works great, with merged columns.


In short, my custom subclasses are somehow preventing my main window 
from become key or main--but only when I use an even number of instances 
of such subclasses.  When I use 1, 3, or 5 instances, everything is fine.


I am running Xcode 2.4.1 on OS 10.4.  I have already set the Nib file 
format to "Pre-10.2", because I've heard that newer formats can cause 
problems with custom subclasses.


I know that this is a strange story...I hope that there is a simple 
explanation that will make me look stupid.  My application is working, 
but I just can't stand having to use such a blatant kludge as a hidden 
instance of my custom subclass.

___

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 [EMAIL PROTECTED]


Core Data and retain count

2008-03-02 Thread Kimo
I have a Core Data app that has several entities.  One entity, Window,  
contains several properties such as openAtLaunch, windowName, and  
wController.  The wController attributes are Transformable, Optional  
and Transient.  The data are presented on a list, and when the user  
double-clicks a record, a window controller is allocated and set as  
the value for the property wController and then the window controller  
is released, giving it a retain count of 1.


However, and this is the weird part, whenever I change another  
property of the Window managed object, such as the openAtLaunch value,  
the window controller receives a 'retain'.  Even if I just edit the  
windowName property, the wController value (the window controller)  
gets another retain.  So by the time the user wants to delete a  
managed object from the list, the window controller could have a high  
value and is never released!


My question is, why would changing a property value cause another  
property to have its retain count increase?


Any insight would be appreciated.

Thanks.
___

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 [EMAIL PROTECTED]


Re: Custom View drawn twice?

2008-03-02 Thread Ben Lachman
So I tried this and wasn't able to get it to display the behavior,  
which makes me assume the issue must be the interaction with the rest  
of the views in the hierarchy.  If I turn off all calls to  
setNeedsDisplay... I don't get the double drawing, but I also don't  
get UI updates.  The view hierarchy looks like this:


BackgroundView (Opaque) -> (scrollview) -> RVTextView (Not Opaque)  - 
> MagnetClipView (not Opaque, draws drop shadow)	-> MagnetView (not  
opaque)

   
 -> RVImageView (subclass of NSImageView)

So I set logging on all setNeedsDisplay... and drawRect methods in  
this hierarchy as well as logging on every time through the run loop  
(break,log & continue on __CFRunLoopRun) during a selection drag (the  
action that causes the double drawing effect) and this is what I get  
(cleaned up for readability).  The thing I wonder about is the number  
of setNeedDisplayInRect: calls to BackgroundView--they all seem to be  
called from propagating dirty rect from non-opaque subviews though.   
Other than that I don't see anything that looks odd.  Anyone?


**Top of Run loop**
17.617 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{18, 56},  
{400, 16}}
17.618 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{18, 438},  
{243, 32}}
17.618 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{18, 470},  
{400, 24}}

17.619 RVApp[25760] BackgroundView: drawRect:
17.629 RVApp[25760] TextView: drawRect:
17.635 RVApp[25760] MagnetClipView: setNeedsDisplayInRect:{{0, 0},  
{160, 200}}

17.636 RVApp[25760] MagnetClipView: drawRect:
17.638 RVApp[25760] MagnetClipView: setsNeedsDisplay:NO
17.638 RVApp[25760] RVImageView: drawRect:
17.649 RVApp[25760] MagnetView: drawRect:
17.653 RVApp[25760] BackgroundView: setsNeedsDisplay:NO
**Top of Run loop**
17.830 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{18, 72},  
{400, 382}}
17.830 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{261,  
454}, {157, 16}}

17.831 RVApp[25760] BackgroundView: drawRect:
17.842 RVApp[25760] TextView: drawRect:
17.848 RVApp[25760] MagnetClipView: setNeedsDisplayInRect:{{0, 0},  
{160, 176}}

17.849 RVApp[25760] MagnetClipView: drawRect:
17.852 RVApp[25760] RVImageView: setNeedsDisplayInRect:{{0, 0}, {128,  
128}}
17.852 RVApp[25760] MagnetView: setNeedsDisplayInRect:{{0, 0}, {160,  
176}}

17.852 RVApp[25760] RVImageView: drawRect:
17.859 RVApp[25760] RVImageView: setsNeedsDisplay:NO
17.860 RVApp[25760] MagnetView: drawRect:
17.861 RVApp[25760] BackgroundView: setsNeedsDisplay:NO
17.862 RVApp[25760] MagnetClipView: setsNeedsDisplay:NO
17.862 RVApp[25760] MagnetView: setsNeedsDisplay:NO
**Top of Run loop**
18.075 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{18, 56},  
{400, 16}}
18.075 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{18, 232},  
{400, 144}}
18.075 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{18, 454},  
{243, 16}}
18.075 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{18, 470},  
{400, 24}}

18.076 RVApp[25760] BackgroundView: drawRect:
18.085 RVApp[25760] TextView: drawRect:
18.091 RVApp[25760] MagnetClipView: setNeedsDisplayInRect:{{0, 0},  
{160, 200}}

18.091 RVApp[25760] MagnetClipView: drawRect:
18.094 RVApp[25760] MagnetClipView: setsNeedsDisplay:NO
18.094 RVApp[25760] RVImageView: drawRect:
18.101 RVApp[25760] MagnetView: drawRect:
18.102 RVApp[25760] BackgroundView: setsNeedsDisplay:NO
**Top of Run loop**
18.263 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{18, 72},  
{400, 176}}
18.264 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{18, 376},  
{400, 78}}
18.264 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{261,  
454}, {157, 16}}

18.265 RVApp[25760] BackgroundView: drawRect:
18.275 RVApp[25760] TextView: drawRect:
18.281 RVApp[25760] MagnetClipView: setNeedsDisplayInRect:{{0, 0},  
{160, 176}}

18.282 RVApp[25760] MagnetClipView: drawRect:
18.285 RVApp[25760] RVImageView: setNeedsDisplayInRect:{{0, 0}, {128,  
128}}
18.285 RVApp[25760] MagnetView: setNeedsDisplayInRect:{{0, 0}, {160,  
176}}

18.285 RVApp[25760] RVImageView: drawRect:
18.293 RVApp[25760] RVImageView: setsNeedsDisplay:NO
18.294 RVApp[25760] MagnetView: drawRect:
18.296 RVApp[25760] BackgroundView: setsNeedsDisplay:NO
18.298 RVApp[25760] MagnetClipView: setsNeedsDisplay:NO
18.298 RVApp[25760] MagnetView: setsNeedsDisplay:NO
**Top of Run loop**
18.460 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{18, 56},  
{400, 16}}
18.460 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{18, 152},  
{400, 32}}
18.460 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{18, 248},  
{400, 128}}
18.460 RVApp[25760] BackgroundView: setNeedsDisplayInRect:{{18, 454},  
{243, 16}}
18.460 RVApp[25760] BackgroundView: setNeedsDisplayInRect:

NSString and string contains

2008-03-02 Thread Tom Jones

Hello,
I'm fairly new to Cocoa, so please excuse me if I'm not using the  
right terminology.


I have an NSArray which contains String values and I want to loop  
though it and determine if any of those string contain words I'm  
looking for. I have tried but have been unsuccessful.


Example...

unsigned arrayCount = [array count];
for(unsigned j = 0; j < arrayCount; j++)
 {
id obj;
obj = [array objectAtIndex:j];
/* Here is where I'm having trouble
I know this is not real :-)
if ( [obj inStr:@"home"])
{
NSLog(@"I found home, %@", obj);
}
*/
}


I hope the example helps, thanks,
tom

___

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 [EMAIL PROTECTED]


Re: NSString and string contains

2008-03-02 Thread Seth Willits

On Mar 2, 2008, at 12:31 PM, Tom Jones wrote:


id obj;
obj = [array objectAtIndex:j];
/* Here is where I'm having trouble
I know this is not real :-)
if ( [obj inStr:@"home"])



http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#/ 
/apple_ref/doc/uid/2154-rangeOfString_options_range_



--
Seth Willits




___

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 [EMAIL PROTECTED]


Re: NSString and string contains

2008-03-02 Thread Andrew Merenbach

Hi, Tom,

You probably want to use enumerators and something like the following  
code:



NSEnumerator *e = [array objectEnumerator];
NSString *string;

while ((string = [e nextObject])) {
NSRange range = [string rangeOfString:@"home"];
if (range.location != NSNotFound) {
NSLog(@"I found home in the string %@", string);
}
}


The enumerator does what your for-loop does, except that it gives you  
the objects rather than making you use -objectAtIndex:.  Additionally,  
the NSRange struct gives you a location, from -rangeOfString:, where  
the found string -- if it isn't the location NSNotFound, which may be  
self-explanatory -- where the string was found, and thus tells you  
whether it was found in the first place.


Cheers,
Andrew



On Mar 2, 2008, at 12:31 PM, Tom Jones wrote:


Hello,
I'm fairly new to Cocoa, so please excuse me if I'm not using the  
right terminology.


I have an NSArray which contains String values and I want to loop  
though it and determine if any of those string contain words I'm  
looking for. I have tried but have been unsuccessful.


Example...

unsigned arrayCount = [array count];
for(unsigned j = 0; j < arrayCount; j++)
{
id obj;
obj = [array objectAtIndex:j];
/* Here is where I'm having trouble
I know this is not real :-)
if ( [obj inStr:@"home"])
{
NSLog(@"I found home, %@", obj);
}
*/
}


I hope the example helps, thanks,
tom

___

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/andrew.merenbach%40ucla.edu

This email sent to [EMAIL PROTECTED]


___

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 [EMAIL PROTECTED]


Re: NSString and string contains

2008-03-02 Thread j o a r


On Mar 2, 2008, at 10:44 PM, Andrew Merenbach wrote:

You probably want to use enumerators and something like the  
following code:



...and if you're on 10.5 (or later - even if that's kind of unlikely  
at this point) you'd use the new FAST enumerator:


for (NSString *string in array)
{
// Do stuff with the string
}

j o a r


___

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 [EMAIL PROTECTED]


Re: NSString and string contains

2008-03-02 Thread Andrew Merenbach
Yep, I would've suggested fast enumeration, as I use them myself  
regularly, except that a beginner might (or might not) find the  
traditional paradigm easier.


Cheers,
Andrew

On Mar 2, 2008, at 2:01 PM, j o a r wrote:



On Mar 2, 2008, at 10:44 PM, Andrew Merenbach wrote:

You probably want to use enumerators and something like the  
following code:



...and if you're on 10.5 (or later - even if that's kind of unlikely  
at this point) you'd use the new FAST enumerator:


for (NSString *string in array)
{
// Do stuff with the string
}

j o a r




___

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 [EMAIL PROTECTED]


NSFontManager Initialization

2008-03-02 Thread Gordon Apple
I am using NSFontManager and NSFontPanel to (eventually) extract a glyph
as a draw object.  The following code fails unless the font panel has
previously been used in a text field.

NSFontManager* fmgr = [NSFontManager sharedFontManager];
NSFont* theFont = [fmgr selectedFont];

After I select the font and size in the panel, "theFont" will always
return nil.  If I first use the panel with a text view, it will work
properly.  Also, a few times, I couldn't set the size in the panel's size
field.  Bug report time? Or is there something else I could do to get it
properly initialized?

___

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 [EMAIL PROTECTED]


Re: Reading word at mouse pointer w/o Universal Access

2008-03-02 Thread Adam Leonard
Just so you know, the Accessibility API has AXMakeProcessTrusted(),  
which will enable access to the API for just your application. It  
requires that it be called from a process running as root, so the user  
needs to enter his/her password, but otherwise it is fully automatic.


I blogged about it a while ago here: http://caffeinatedcocoa.com/blog/?p=12
There is also some sample code included.

Adam Leonard

On Mar 2, 2008, at 6:24 AM, Ryan Homer wrote:


Steve,

While I agree that the user should decide whether or not to allow  
the application to access another's text, to me, that's exactly what  
they are doing if they decide to use the application. It is going to  
be a dictionary-type application, so if the user installs it, s/he  
would be fully aware that its use would entail moving the mouse  
pointer over a word in another application. The application would be  
just about useless without that feature - so might as well delete it  
if you don't want that feature. It's just that I don't want to  
require that the user have to enable access for assistive devices.  
The first time I came across that, I was hesitant to enable that  
without knowing more about it and how many more services I would be  
keeping running all the time in the background, etc. This made me  
hesitant to even use the application that wanted to turn this on.


On 28-Feb-08, at 8:59 PM, Steve Christensen wrote:

I don't have specific knowledge but, yes, I would expect that the  
dictionary support is a trusted part of the OS, thus can be hooked  
into every application.


As far as I know, if you want to touch another application's UI,  
you have to go through accessibility. From the OS's point of view  
yours is just another application, so it seems reasonable that the  
user should decide whether or not to allow your application to see  
what's going on in another.


steve


On Feb 28, 2008, at 5:33 PM, Ryan Homer wrote:

Let me clarify that it doesn't seem to be the Dictionary  
application that's reading the word at the mouse pointer but  
rather the OS itself or some daemon, perhaps, when  Ctrl-Option-D  
is pressed. It might be the process called DictionaryPanel that  
seems to always be running.


Anyway, if anyone can point me to the appropriate functions/ 
methods/classes that might be involved in doing such a thing w/o  
the aforementioned techniques, please let me know.


On 28-Feb-08, at 8:27 PM, Ryan Homer wrote:

I've read this post (http://lists.apple.com/archives/accessibility-dev/2006/Aug/msg7.html 
) about using the accessibility options to read the text under  
the cursor. However, this requires that the user enable access  
for assistive devices in System Preferences. The application must  
therefore check for that. It also seems quite complicated; I  
don't want to have to deal with glyphs and the like - I only want  
the text under the cursor, full stop.


The Dictionary application is able to read a word under the  
cursor without enabling access for assistive devices.


Does anyone therefore know of an alternative way to do this?

Thanks in advance.


___

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/hzc.lists 
%40gmail.com


This email sent to [EMAIL PROTECTED]


___

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/adam%40caffeinatedcocoa.com

This email sent to [EMAIL PROTECTED]



___

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 [EMAIL PROTECTED]


Re: Problems with ScriptingBridge and iTunes

2008-03-02 Thread has

Jonathan 'Wolf' Rentzsch wrote:


On Mar 1, 2008, at 7:28 PM, Hannes Petri wrote:
iTunesApplication *iTunes = [[SBApplication alloc]  
initWithBundleIdentifier:@"com.apple.iTunes"];

iTunesTrack *currentTrack = [iTunes currentTrack];

if ([currentTrack isKindOfClass:[iTunesFileTrack class]]) {
…
}

The problem is, that the class of the object returned is _always_  
iTunesTrack, and not iTunesFileTrack, as i expect it to be. If i  
run the following applescript code:


tell application "iTunes" to current track

I get a "file track", which makes it possible to fetch the path  
using the "location" attribute. If I, in the ObjC example, try  
[currentTrack location], I'm told that it doesn't respond to that  
selector.
I have made certain that the object is of class iTunesTrack by  
typing 'po [currentTrack class]' in gdb.


I ran into the same thing -- Scripting Bridge may play games  
isKindOfClass: that bite us.


Short explanation: Scripting Bridge is made of LAME and FAIL.

Longer explanation:

The fundamental problem with Scripting Bridge is that it basically  
lies about how application scripting works.


The key concept to grasp is that Apple event IPC is based on RPC plus  
simple relational queries. It is *not* an object-oriented IPC  
mechanism à la DO/COM/CORBA/etc.


For convenience and conciseness, AppleScript implements a couple of  
magical behaviours at the compiler/interpreter level and dresses the  
whole lot up in an OO-like syntax. This OO resemblance is quite  
superficial, however, and beneath the surface the original RPC+query  
semantics are preserved intact. This makes AppleScript easier to use,  
at least for the common-case usages. The tradeoff is that, because the  
syntax obfuscates the semantics, it's difficult for users to form a  
complete, accurate understanding of how Apple event IPC actually  
works. Still, for the majority of AppleScript users, even a flawed,  
incomplete mental model is usually 'good enough' to get the results  
they need, so while these obfuscations do cause some problems they  
aren't disastrous.


Scripting Bridge, however, goes much further. Not only does it apply a  
generous amount of OO-like syntactic sugar on the underlying RPC+query  
mechanism, it also tries to impose its own set of OO-like semantics as  
well. This is a Bad Idea for various reasons, many of which previously  
I've discussed here and elsewhere (Google if you want to read more).



In this particular case, the first major problem is that because SB  
creates 'proxy classes' based on the class definitions in the  
application's dictionary, users naturally assume that instances of  
these classes directly represent objects in the scriptable  
application. This is, after all, how Distributed Objects and other  
object-oriented IPC mechanisms do things, after all: call a method on  
a proxy object, and the same method is invoked on the remote object  
and its result returned.


Alas, this assumption is completely and utterly wrong. Remember, Apple  
event IPC is RPC+queries, *not* OOP. While SB objects may look and  
superficially behave like DO-esque proxy objects, they are actually  
just thin wrappers around Apple event queries, dressed up to look like  
something else. Apple event queries have no real meaning in  
themselves; it's only when you stick them in an Apple event and send  
them to an application that they are evaluated to identify actual  
application objects. Therefore, by extension, there is no direct  
relationship between an SB object and an application object: calling a  
method on an SB object is not guaranteed to invoke an operation on a  
remote object; heck, an SB object isn't even guaranteed to map to a  
specific remote object, or the same object as the last time it was  
used, or any object at all!



Conversely, when you ask Scripting Bridge for [iTunes currentTrack],  
SB doesn't actually know what iTunes current track is, or what class  
it is, or even if it exists at all. To get that kind of information,  
you have to ask the application itself by sending it the relevant  
Apple event. All SB does is construct an Apple event query identifying  
the application object's 'current track' property and stuffs it in one  
of its faux-proxy objects for the client to manipulate further.


Which brings us to the second major problem: in order to present its  
pseudo-OO API, Scripting Bridge uses the type information given in the  
application dictionary and extracted from Apple event queries to  
determine which class of wrapper to put around a given query object.  
This wrapper then determines which operations you can perform using  
that query object - which would be perfectly okay if Apple event IPC  
followed OO rules, but it doesn't. As long as an Apple event query is  
grammatically correct it's perfectly legal to use, and it's up to the  
application evaluating it to decide what, if any, object(s) it  
identifies.


For example, 'document 1 of name of ch

Re: Subclassing NSOutlineView causes failure of window to become main or key

2008-03-02 Thread John Stiles

Is anything printed to the Run Log or Console?

Dennis Hartigan-O'Connor wrote:
I'm trying to use a subclass of NSOutlineView to allow merged columns, 
so that some cells can run over their bounds, using methods I read 
about at:


http://www.mactech.com/articles/mactech/Vol.18/18.11/1811TableTechniques/index.html 



I have four instances of my custom subclass organized in an NSTabView.

I have the rather strange problem that my program runs, without 
crashing, and displays the tables with merged columns just as I 
desire.  However, the main window fails to become either main or key, 
so no input is accepted from the user.


I've done a lot of work trying to diagnose this problem and I have two 
key results:


1) Using NSOutlineViews, everything works fine.  In particular, by 
using windowDidBecomeKey and windowDidBecomeMain methods, I find that 
the main window becomes both key and main, and accepts user input, and 
everything works fine.


2) In an attempt to diagnose this problem, I created an "empty" 
subclass of NSOutlineView, which behaves exactly the same as 
NSOutlineView, because no methods are overwritten.  Here's the really 
strange part.  If I set ONE OR THREE of my four NSOutlineViews to the 
custom "empty class", everything works fine--the application runs just 
as if I were using four NSOutlineViews.  windowDidBecomeKey and 
windowDidBecomeMain are both called.  If I set TWO OR FOUR of my four 
NSOutlineViews to the custom "empty class", then the main window fails 
to become either main or key and no input is accepted.  
windowDidBecomeKey and windowDidBecomeMain aren't called.


Believe it or not, I've actually been able to make everything work by 
adding a FIFTH instance of my custom subclass (providing merged 
columns) to the window and setting it to be hidden.  When I do this, 
my whole application works great, with merged columns.


In short, my custom subclasses are somehow preventing my main window 
from become key or main--but only when I use an even number of 
instances of such subclasses.  When I use 1, 3, or 5 instances, 
everything is fine.


I am running Xcode 2.4.1 on OS 10.4.  I have already set the Nib file 
format to "Pre-10.2", because I've heard that newer formats can cause 
problems with custom subclasses.


I know that this is a strange story...I hope that there is a simple 
explanation that will make me look stupid.  My application is working, 
but I just can't stand having to use such a blatant kludge as a hidden 
instance of my custom subclass.

___

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/jstiles%40blizzard.com

This email sent to [EMAIL PROTECTED]

___

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 [EMAIL PROTECTED]


Re: Problems with ScriptingBridge and iTunes

2008-03-02 Thread Adam P Jenkins
Just call the "get" method on the track object that currentTrack  
returns to get the iTunesFileTrack object.  I.e. this works


iTunesFileTrack *currentTrack = [[iTunes currentTrack] get];
NSLog("location is %@", currentTrack.location);

The documentation for the "get" method from the SBObject.h header is:

	// Evaluate the object by sending it to the target application.   
Depending on what
	// the object points to, the result may be a Foundation object such  
as an NSString
	// (for most properties), an NSAppleEventDescriptor (for properties  
of a type with

// no Foundation equivalent), or another SBObject (for most elements).

Another example of where you need to use it in the iTunes SB interface  
is when accessing iTunes.selection property, which returns an  
SBObject, but then if you call "get" on it,  you get an NSCFArray of  
tracks, which is what you wanted in the first place.  I'm not sure  
what the logic is behind the "get" method, but there it is.


Adam

On Mar 1, 2008, at 8:28 PM, Hannes Petri wrote:


Hello!

I want to retrieve the path to the currently played file in iTunes.  
I thought scripting bridge would be the perfect tool for this,  
however i've run into some problem. I have this code:


iTunesApplication *iTunes = [[SBApplication alloc]  
initWithBundleIdentifier:@"com.apple.iTunes"];

iTunesTrack *currentTrack = [iTunes currentTrack];

if ([currentTrack isKindOfClass:[iTunesFileTrack class]]) {
…
}

The problem is, that the class of the object returned is _always_  
iTunesTrack, and not iTunesFileTrack, as i expect it to be. If i run  
the following applescript code:


tell application "iTunes" to current track

I get a "file track", which makes it possible to fetch the path  
using the "location" attribute. If I, in the ObjC example, try  
[currentTrack location], I'm told that it doesn't respond to that  
selector.
I have made certain that the object is of class iTunesTrack by  
typing 'po [currentTrack class]' in gdb.


Very thankful for help!


Hannes Petri___

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/adam%40thejenkins.org

This email sent to [EMAIL PROTECTED]


___

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 [EMAIL PROTECTED]


Core Data opens files as empty

2008-03-02 Thread Jamie Phelps
I'm sorry if this has been covered, but I searched the archives (http://moourl.com/x50hf 
) and didn't find any answers.


I just went through the Core Data tutorial here: http://developer.apple.com/cocoa/coredatatutorial/index.html 
 Everything went well except that when I save a document and then  
open it back up, it displays as empty. If I save a document as XML, it  
still exhibits the blank document behavior but if I open it in  
TextMate, I can see that the document actually contains the data I  
saved.


Anyone have experience and/or a solution for this issue?

Thanks,
Jamie
___

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 [EMAIL PROTECTED]


Render an animation in a bitmap file (CARenderer)

2008-03-02 Thread Martin

Hi,

I'd like to render a CALayer animation in a series of bitmap files  
rather that in an NSView.


I've succeeded  in rendering 1 frame in a bitmap file by :
- creating a NSOpenGLContext
- creating a CARenderer (named renderer)
- calling the following code:

[renderer beginFrameAtTime:0.0 timeStamp:NULL];
[renderer addUpdateRect:CGRectMake(0.0, 0.0, _width, _height)];
[renderer render];
[renderer endFrame];

- saving the content of the context in a bitmap file

Now I'd like to do the same thing for each frame of an animation. But  
I have absolutely no idea on how to do this...

- at what point in the code should I add the animation to the layer?
- I've tried different values for the first argument of  
beginFrameAtTime:timeStamp:, but only the 1st frame is rendered?

- why does [renderer nextFrameTime] always return "inf"?

Thanks,
-Martin
___

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 [EMAIL PROTECTED]


Re: Problems with ScriptingBridge and iTunes

2008-03-02 Thread Adam P Jenkins

On Mar 2, 2008, at 6:16 PM, Adam P Jenkins wrote:

Just call the "get" method on the track object that currentTrack  
returns to get the iTunesFileTrack object.  I.e. this works


iTunesFileTrack *currentTrack = [[iTunes currentTrack] get];
NSLog("location is %@", currentTrack.location);

The documentation for the "get" method from the SBObject.h header is:

	// Evaluate the object by sending it to the target application.   
Depending on what
	// the object points to, the result may be a Foundation object such  
as an NSString
	// (for most properties), an NSAppleEventDescriptor (for properties  
of a type with
	// no Foundation equivalent), or another SBObject (for most  
elements).


Another example of where you need to use it in the iTunes SB  
interface is when accessing iTunes.selection property, which returns  
an SBObject, but then if you call "get" on it,  you get an NSCFArray  
of tracks, which is what you wanted in the first place.  I'm not  
sure what the logic is behind the "get" method, but there it is.


I just read the detailed and very informative post that "has" just  
posted about AppleScript's event semantics and scripting bridge, and  
now I understand what the "get" method is for and why it needs to be  
called.  This also made me realize that what I posted above isn't  
really safe since currentTrack won't always be a iTunesFileTrack.  So  
really you'd want something like:


iTunesTrack *currentTrack = [iTunes.currentTrack get];
if ([currentTrack isKindOfClass:[iTunesFileTrack class]]) {
  iTunesFileTrack *fileTrack = (iTunesFileTrack*)currentTrack;
  NSLog("location = %@", fileTrack.location);
}


___

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 [EMAIL PROTECTED]


Subview bounds resizing when frame resizes

2008-03-02 Thread Steve Weller


I have a custom view with a custom subview. I can't seem t make the  
bounds of the subview stick. When the view changes the subview's  
frame, I want the subview's bounds to stay exactly as I set them the  
first time. The whole point of having this subview is to have a  
separate coordinate system.


I create the subview like this:

// Add page into our view
pageView = [[BTPPPageView alloc] initWithFrame:[self pageFrame]];
	[pageView  
setBounds:NSMakeRect(0,0,pageBoundsSize.width,pageBoundsSize.height)];

[self addSubview:pageView];

and I reposition the subview's frame when the view's frame changes:

[pageView setFrame:[self pageFrame]];

The subview bounds are set correctly at the start, but if I make the  
subview's frame larger, the bounds are scaled larger too. I thought  
from this in the NSView docs that the subview's bounds would stay fixed:


If your view does not use a custom bounds rectangle, this method also  
sets your view bounds to match the size of the new frame. You specify  
a custom bounds rectangle by calling setBounds:, setBoundsOrigin:,  
setBoundsRotation:, or setBoundsSize:explicitly. Once set, NSView  
creates an internal transform to convert from frame coordinates to  
bounds coordinates.


I am using setBounds, so why is it not preventing the scaling? My view  
has the Autoresizes subviews flag off. The view is created in IB, the  
subview in code, as above.


--
Blog:  http://www.bagelturf.com/   Photos: http://bagelturf.smugmug.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 [EMAIL PROTECTED]


Replace NSPopupButton Menu/Binding

2008-03-02 Thread Keith Duncan
I have an NSPopupButton whose menu I need to change based on a model  
property. I'm observing selection.property of the relevant  
NSArrayController to be notified when the menu needs to change. I need  
to alternate between a provided menu and a content array provided by  
another array controller.


I have it working with the code below it just seems awfully long  
winded to accomplish something seemingly simple, I was hoping someone  
could take a look at it and point out where I could improve my  
implementation.


Thanks,
Keith

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object  
change:(NSDictionary *)change context:(void *)context {
if ([[keyPath lastKeyPathComponent]  
isEqualToString:KDAlarmTypeKey]) {

NSString *alarmNameSubpath = nil;
if ([[object valueForKeyPath:keyPath] integerValue] == ITUNES) {
alarmNameSubpath = KDAlarmNameKey;

[advancedAlarmNameButton unbind:NSContentBinding];
[advancedAlarmNameButton unbind:NSContentValuesBinding];

[advancedAlarmNameButton removeAllItems];
[advancedAlarmNameButton setMenu:[[sourceMenu copy] 
autorelease]];
} else {
alarmNameSubpath = KDBackupAlarmNameKey;

[advancedAlarmNameButton removeAllItems];
			[advancedAlarmNameButton bind:NSContentBinding  
toObject:backupAlarmsController withKeyPath:@"arrangedObjects"  
options:nil];
			[advancedAlarmNameButton bind:NSContentValuesBinding  
toObject:backupAlarmsController withKeyPath:@"arrangedObjects.key"  
options:nil];

}

		[advancedAlarmNameButton bind:NSSelectedValueBinding  
toObject:calendarController withKeyPath:[NSString  
keyPathForComponents:@"selection", alarmNameSubpath, nil] options:nil];


		// This is a dirty hack, setting the menu/binding the selected value  
seems to disable the selected menu item!?

[[advancedAlarmNameButton selectedItem] setEnabled:YES];
	} else [super observeValueForKeyPath:keyPath ofObject:object  
change:change context:context];

}
___

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 [EMAIL PROTECTED]


Re: Core Data opens files as empty

2008-03-02 Thread mmalc crawford


On Mar 2, 2008, at 3:19 PM, Jamie Phelps wrote:

I'm sorry if this has been covered, but I searched the archives (http://moourl.com/x50hf 
) and didn't find any answers.


I just went through the Core Data tutorial here:http://developer.apple.com/cocoa/coredatatutorial/index.html 
 Everything went well except that when I save a document and then  
open it back up, it displays as empty. If I save a document as XML,  
it still exhibits the blank document behavior but if I open it in  
TextMate, I can see that the document actually contains the data I  
saved.





mmalc

___

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 [EMAIL PROTECTED]


Re: Handling mouse click event on a NSButton

2008-03-02 Thread I. Savant

I have a NSButton and I would like to have some code executed when the
button is clicked. Special circunstances for this is that my button is
created purely in code, there are no nib files on the project and also
no use of the Interface Builder, and nor can it be, because I'm
developing a cross-platform library. I haven't found how to do that in
those special circunstances.


  This is covered in the introductory Cocoa material. See:

http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_5.html

  The target/action mechanism works the same in code as it does in  
IB. It's just that in code, you have to explicitly set the target/ 
action.


--
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 [EMAIL PROTECTED]


Re: Problems with ScriptingBridge and iTunes

2008-03-02 Thread has

Adam P Jenkins wrote:

I'm not sure what the logic is behind the "get" method, but there it  
is.



It's completely logical if you appreciate that Apple event IPC is RPC 
+queries. To tell a scriptable application to perform an operation,  
you send it a command (Apple event). If the command operates on  
application objects, you identify those objects using simple first- 
class relational queries ("object specifiers" in Apple event jargon,  
or what AppleScripters misleadingly call "references") which you  
supply as arguments (parameters) to the command. As a rough analogy,  
think of using XPath queries over XML-RPC.


It's a simple, really rather elegant, and surprisingly powerful and  
flexible conceptual model, whose simplicity, elegance, power and  
flexibility is, in execution, horribly distorted and obscured by  
AppleScript's - and, to an even greater extent, Scripting Bridge's -  
crazy mad love affair with pseudo-OO syntax and poorly documented  
'magic' behaviours, until the number of folks who have a completely  
accurate and comprehensive understanding of how this stuff really  
works can probably be counted on the fingers of one hand.



There's a brief summary of the basic principles behind Apple event IPC  
included in the appscript documentation. For your convenience, the  
Ruby version is currently online at:



http://rb-appscript.rubyforge.org/doc/appscript-manual/02_aboutappscripting.html

For a more detailed discussion see the two PDF papers by William Cook  
(one of the original AppleScript designers) on the appscript links page:


http://appscript.sourceforge.net/links.html

Matt Neuburg's "AppleScript: The Definitive Guide" (2nd ed.) is also  
well worth a read.


HTH

has
--
http://appscript.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 [EMAIL PROTECTED]


Handling mouse click event on a NSButton

2008-03-02 Thread Felipe Monteiro de Carvalho
Hello,

I have a NSButton and I would like to have some code executed when the
button is clicked. Special circunstances for this is that my button is
created purely in code, there are no nib files on the project and also
no use of the Interface Builder, and nor can it be, because I'm
developing a cross-platform library. I haven't found how to do that in
those special circunstances.

thank you very much,
-- 
Felipe Monteiro de Carvalho
___

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 [EMAIL PROTECTED]


Re: Bypassing inter-cell navigation for NSButtonCell in NSOutlineView

2008-03-02 Thread Rosyna

Have you tried overriding

- (BOOL)canFocusCell:(NSCell *)cell atTableColumn:(NSTableColumn  
*)tableColumn row:(NSInteger)row;


to return NO in an outline view subclass?


On Mar 2, 2008, at 6:42 AM, Nicholas Riley wrote:

In Leopard, checkboxes in my NSOutlineViews get keyboard focus when  
I press Tab.  I don't want this to happen.





---
Sincerely,
Rosyna Keller
Technical Support/Carbon troll/Always needs a hug

Unsanity: Unsane Tools for Insanely Great People

It's either this, or imagining Phil Schiller in a thong.

___

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 [EMAIL PROTECTED]


Re: Core Data opens files as empty

2008-03-02 Thread Andrew Merenbach

Hi, Jamie,

Have you set your array controller or tree controller to "prepare  
content automatically"?


Cheers,
Andrew

On Mar 2, 2008, at 3:19 PM, Jamie Phelps wrote:

I'm sorry if this has been covered, but I searched the archives (http://moourl.com/x50hf 
) and didn't find any answers.


I just went through the Core Data tutorial here: http://developer.apple.com/cocoa/coredatatutorial/index.html 
 Everything went well except that when I save a document and then  
open it back up, it displays as empty. If I save a document as XML,  
it still exhibits the blank document behavior but if I open it in  
TextMate, I can see that the document actually contains the data I  
saved.


Anyone have experience and/or a solution for this issue?

Thanks,
Jamie
___

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/andrew.merenbach%40ucla.edu

This email sent to [EMAIL PROTECTED]


___

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 [EMAIL PROTECTED]


Re: Core Data opens files as empty

2008-03-02 Thread mmalc crawford


On Mar 2, 2008, at 4:39 PM, mmalc crawford wrote:


 I can see that the document actually contains the data I saved.





Sorry, didn't read that last line...
Most likely you missed a step.
Compare with a similar example in 


mmalc

___

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 [EMAIL PROTECTED]


Re: Subclassing NSOutlineView causes failure of window to become main or key

2008-03-02 Thread Dennis Hartigan-O'Connor

Thanks, John,

In all these cases, I can use NSLog to print to the Run Log--but no 
errors are printed there by the system.


In all cases, the Console Log is blank.

In cases where the window doesn't become main or key, if I attach the 
debugger I find that the thread list looks exactly the SAME as when the 
window does become main or key:


#0  0x9000b348 in mach_msg_trap
#1  0x9000b29c in mach_msg
#2  0x907ddad8 in __CFRunLoopRun
#3  0x907dd3dc in CFRunLoopRunSpecific
#4  0x9329bb20 in RunCurrentEventLoopInMode
#5  0x9329b1b4 in ReceiveNextEventCommon
#6  0x9329b020 in BlockUntilNextEventMatchingListInMode
#7  0x937a1bc4 in _DPSNextEvent
#8	0x937a1888 in -[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:]

#9  0x9379ddcc in -[NSApplication run]
#10 0x9388e974 in NSApplicationMain
#11 0x00011fa8 in main at main.m:13

I don't fully understand this information but I'm assuming it represents 
the normal event loop, since it looks exactly the same as when the 
application runs perfectly.



John Stiles wrote:

Is anything printed to the Run Log or Console?

Dennis Hartigan-O'Connor wrote:
I'm trying to use a subclass of NSOutlineView to allow merged columns, 
so that some cells can run over their bounds, using methods I read 
about at:


http://www.mactech.com/articles/mactech/Vol.18/18.11/1811TableTechniques/index.html 



I have four instances of my custom subclass organized in an NSTabView.

I have the rather strange problem that my program runs, without 
crashing, and displays the tables with merged columns just as I 
desire.  However, the main window fails to become either main or key, 
so no input is accepted from the user.


I've done a lot of work trying to diagnose this problem and I have two 
key results:


1) Using NSOutlineViews, everything works fine.  In particular, by 
using windowDidBecomeKey and windowDidBecomeMain methods, I find that 
the main window becomes both key and main, and accepts user input, and 
everything works fine.


2) In an attempt to diagnose this problem, I created an "empty" 
subclass of NSOutlineView, which behaves exactly the same as 
NSOutlineView, because no methods are overwritten.  Here's the really 
strange part.  If I set ONE OR THREE of my four NSOutlineViews to the 
custom "empty class", everything works fine--the application runs just 
as if I were using four NSOutlineViews.  windowDidBecomeKey and 
windowDidBecomeMain are both called.  If I set TWO OR FOUR of my four 
NSOutlineViews to the custom "empty class", then the main window fails 
to become either main or key and no input is accepted.  
windowDidBecomeKey and windowDidBecomeMain aren't called.


Believe it or not, I've actually been able to make everything work by 
adding a FIFTH instance of my custom subclass (providing merged 
columns) to the window and setting it to be hidden.  When I do this, 
my whole application works great, with merged columns.


In short, my custom subclasses are somehow preventing my main window 
from become key or main--but only when I use an even number of 
instances of such subclasses.  When I use 1, 3, or 5 instances, 
everything is fine.


I am running Xcode 2.4.1 on OS 10.4.  I have already set the Nib file 
format to "Pre-10.2", because I've heard that newer formats can cause 
problems with custom subclasses.


I know that this is a strange story...I hope that there is a simple 
explanation that will make me look stupid.  My application is working, 
but I just can't stand having to use such a blatant kludge as a hidden 
instance of my custom subclass.

___

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/jstiles%40blizzard.com

This email sent to [EMAIL PROTECTED]




___

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 [EMAIL PROTECTED]


Re: NSString and string contains

2008-03-02 Thread Johannes Huning

Or if your're on Leopard using the new enumerator:

NSString *searchFor = @"home";
NSRange range;
for (NSString *string in stringList)
{
   range = [word rangeOfString:searchFor];
   if (range.location != NSNotFound)
   {
  NSLog (@"Yay! '%@' found in '%@'.", searchFor, string);
   }
}

Correct me if I'm wrong.

_
 Johannes H.

On Mar 2, 2008, at 10:44 PM, Andrew Merenbach wrote:


Hi, Tom,

You probably want to use enumerators and something like the  
following code:



NSEnumerator *e = [array objectEnumerator];
NSString *string;

while ((string = [e nextObject])) {
NSRange range = [string rangeOfString:@"home"];
if (range.location != NSNotFound) {
NSLog(@"I found home in the string %@", string);
}
}


The enumerator does what your for-loop does, except that it gives  
you the objects rather than making you use -objectAtIndex:.   
Additionally, the NSRange struct gives you a location, from - 
rangeOfString:, where the found string -- if it isn't the location  
NSNotFound, which may be self-explanatory -- where the string was  
found, and thus tells you whether it was found in the first place.


Cheers,
Andrew



On Mar 2, 2008, at 12:31 PM, Tom Jones wrote:


Hello,
I'm fairly new to Cocoa, so please excuse me if I'm not using the  
right terminology.


I have an NSArray which contains String values and I want to loop  
though it and determine if any of those string contain words I'm  
looking for. I have tried but have been unsuccessful.


Example...

unsigned arrayCount = [array count];
for(unsigned j = 0; j < arrayCount; j++)
{
id obj;
obj = [array objectAtIndex:j];
/* Here is where I'm having trouble
I know this is not real :-)
if ( [obj inStr:@"home"])
{
NSLog(@"I found home, %@", obj);
}
*/
}


I hope the example helps, thanks,
tom

___

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/andrew.merenbach%40ucla.edu

This email sent to [EMAIL PROTECTED]


___

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/john%40quobor.de

This email sent to [EMAIL PROTECTED]


___

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 [EMAIL PROTECTED]


re: Core Data and retain count

2008-03-02 Thread Ben Trumbull

My question is, why would changing a property value cause another
property to have its retain count increase?


No idea.  Why don't you run it in gdb and break on the -retain method  
and get some stack traces ?
This works best if the class you're debugging (in this case the value  
window controller) has a custom retain/release method that you can  
break on instead of NSObject's etc.  If it doesn't, you can trivially  
make one by adding a category on it and putting -retain/-release/- 
autorelease methods on it that simply call super.


So by the time the user wants to delete a managed object from the  
list, the window controller could have a high

value and is never released!


This sounds like a hypothetical concern as opposed to an empirically  
observed leak.  Each retainer is obliged to balance itself out  
eventually.  That's not your problem.  Generally speaking, the retain  
count is an implementation dependent value and not really meaningful  
API.


- Ben

___

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 [EMAIL PROTECTED]


Re: Bypassing inter-cell navigation for NSButtonCell in NSOutlineView

2008-03-02 Thread Nicholas Riley
On Sun, Mar 02, 2008 at 04:24:04PM +0100, Tommy Nordgren wrote:
> >>- Back tabbing into a table will select the last focusable cell.
> >
> >and I can't figure out how to stop that from happening.
> >
> >Help?
> >
>   You probably need to modify your keyDown: method to intercept  
> backtabs as well

My tab order looks like this:

   outline view - button - button - ...

so the first button is focused when I press shift-Tab and focus
transfers to the outline view's NSButtonCell.

On Sun, Mar 02, 2008 at 01:36:01PM -0600, Ricky Sharp wrote:
> >>- Hitting Space will attempt to 'performClick:' on a NSButtonCell  
> >>in the selected row, if there is only one instance in that row.
> >
> >So far, so good.
> >
> >>- Tabbing again focuses the first "focusable" (1) cell, if there is  
> >>one.
> >
> >I don't want the NSButtonCell to ever get focus.
> 
> It sounds like you have full keyboard access turned on.  And, what  
> you're seeing is the correct behavior.
> 
> Be mindful of users that need to to interact with your application via  
> accessibility.

Trying to provide accessibility support is actually how I got in this
mess.  The previous version of this panel looked more like what you
get from System Preferences > International > Language > Edit List -
you can use the keyboard to select a row, but there's no visual
indication of the selected row.  In this version I'm highlighting the
individual rows, and with a row highlighted, as mentioned above, you
can press the space bar to toggle the checkbox.  As such, it's
redundant (not to mention ugly) that the checkbox itself can get
focus.

With VoiceOver enabled, it's even worse; not only the button cell but
the two text cells in the outline view are unnecessarily added to the
tab order.

On Sun, Mar 02, 2008 at 05:58:53PM -0700, Rosyna wrote:
> Have you tried overriding
> 
> - (BOOL)canFocusCell:(NSCell *)cell atTableColumn:(NSTableColumn  
> *)tableColumn row:(NSInteger)row;
> 
> to return NO in an outline view subclass?

Thanks, that works and resolves the VoiceOver focus issue as well, but
this method is not declared in the header file.  Wonder if this was
accidental, or if there's another method I should be using instead.

-- 
Nicholas Riley <[EMAIL PROTECTED]> | 
___

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 [EMAIL PROTECTED]


Re: Reading word at mouse pointer w/o Universal Access

2008-03-02 Thread Nir Soffer


On Feb 29, 2008, at 03:27, Ryan Homer wrote:

I've read this post (http://lists.apple.com/archives/accessibility- 
dev/2006/Aug/msg7.html) about using the accessibility options  
to read the text under the cursor. However, this requires that the  
user enable access for assistive devices in System Preferences. The  
application must therefore check for that. It also seems quite  
complicated; I don't want to have to deal with glyphs and the like  
- I only want the text under the cursor, full stop.


The Dictionary application is able to read a word under the cursor  
without enabling access for assistive devices.


Does anyone therefore know of an alternative way to do this?


You can write a service which let the user to select some text and  
pass it to the service. This will be easy to develop and support, but  
not useful as the built-in dictionary app.


More risky alternative is an input manager, which let poke into any  
Cocoa app data you like without enabling accessibility. However,  
input managers are deprecated and may stop working at some point in  
the future. Writing input manager is easy, but not well documented.


For input manager examples, see:

- http://www.lorax.com/FreeStuff/TextExtras.html - The original input  
manager example code. Show how to watch the first responder which you  
can use to access the text bellow the cursor.
- http://www.culater.net/software/SIMBL/SIMBL.php - framework for  
loading input managers


There is related discussion here: 


Another more evil alternative is APE  - it  
will let you access any app data.



Best Regards,

Nir Soffer

___

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 [EMAIL PROTECTED]


Re: Handling mouse click event on a NSButton

2008-03-02 Thread Felipe Monteiro de Carvalho
Hi, thanks, now I read those docs, but there is still something I
don't understand. There they recommend I should use something like:

[aControl setAction:@selector(deleteRecord:)];

But setAction expectes just a selector as parameter, so it seams to me
that a lot of information about the method to be called is missing.
AFAIK a selector just identifies the name of the method, but the class
to which it bellongs to is missing and also the pointer to it's
instance and the pointer to the method code.

I'm using Cocoa from Pascal using PasCocoa (
http://wiki.lazarus.freepascal.org/PasCocoa ), so I can't use
objective-c language constructions and need to get this working with
just objective-c runtime headers. I tryed to see the assembly for
@selector(something:); but it isn't promissing. It calls a objc_meth_
something that I can't find anywhere.

thanks,
-- 
Felipe Monteiro de Carvalho
___

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 [EMAIL PROTECTED]


Re: Handling mouse click event on a NSButton

2008-03-02 Thread I. Savant

But setAction expectes just a selector as parameter, so it seams to me
that a lot of information about the method to be called is missing.
AFAIK a selector just identifies the name of the method, but the class
to which it bellongs to is missing and also the pointer to it's
instance and the pointer to the method code.


  Read the documentation again. Pay particular attention to the  
"target" concepts in addition to the "action" concepts.


--
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 [EMAIL PROTECTED]


Re: Handling mouse click event on a NSButton

2008-03-02 Thread I . Savant

I'm using Cocoa from Pascal using PasCocoa (
http://wiki.lazarus.freepascal.org/PasCocoa ), so I can't use
objective-c language constructions and need to get this working with
just objective-c runtime headers. I tryed to see the assembly for
@selector(something:); but it isn't promissing. It calls a objc_meth_
something that I can't find anywhere.


  I apologize - I completely missed this part. I see the syntax is  
something like TextField.setStringValue(...); ... I'm not sure how  
that would work with a method that expects a selector. That's a  
question that's probably best posed to the PasCocoa forums.


--
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 [EMAIL PROTECTED]


When in the launch cycle does coredata data become available.

2008-03-02 Thread Adam Gerson
I am trying to programatically get some data from an array controller
when my program launches.

NSArray *allServers = [serverLibraryArrayController arrangedObjects];

This code works just fine with I invoke it with a button click.
However, if I put it in awakeFromNib or ApplicationDidFInishLaunching
it returns nil.

What method can I use so that this action is done automatically when
the program launches, but after core data has loaded data into the
array controller?

Thanks,
Adam
___

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 [EMAIL PROTECTED]


Re: When in the launch cycle does coredata data become available.

2008-03-02 Thread mmalc crawford


On Mar 2, 2008, at 6:36 PM, Adam Gerson wrote:


NSArray *allServers = [serverLibraryArrayController arrangedObjects];

This code works just fine with I invoke it with a button click.
However, if I put it in awakeFromNib or ApplicationDidFInishLaunching
it returns nil.




mmalc

___

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 [EMAIL PROTECTED]


Re: Issue about cocoa Multi-document template

2008-03-02 Thread Doug Knowles
Good point.
In my case, I'm deviating from convention for two purposes:

- I expect the most common use of my application is to have one or very few
documents in existence, and that the user will usually prefer the
application to automatically open whatever document(s) were open when it
last closed, a la Quicken.  I will probably make this behavior a preference
option.

- If there are no documents to automatically open, or if the user holds down
the shift key during launch to suppress auto-open (similar to deferring
auto-launch of applications at login time), instead of opening an empty
document, I present a dialog (modeled on the iWork apps) which offers the
choice of creating a document from a template (again, likely to be a
preferred option) in addition to creating a "blank" document or opening an
existing one.

But I'm not changing or inventing behaviors arbitrarily, which I think
you're cautioning against. I'm anticipating the preferences of my users and
adopting widely accepted alternatives to accommodate them.

Doug K;

On Sun, Mar 2, 2008 at 11:30 AM, Gregory Weston <[EMAIL PROTECTED]> wrote:

> > This behavior is not that I want. I thought the application should not
> > open any window until users explicit open file command arrived.
>
> That's not the standard behavior of document-centric Mac OS X
> applications. The standard behavior is to present the user with a
> new, empty document when the app is launched by double-clicking the
> app icon or when it's activated by clicking the dock icon while no
> documents are open. So my first recommendation is to understand that
> and decided if you really need to deviate.
>
>
___

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 [EMAIL PROTECTED]


Re: Core Data and retain count

2008-03-02 Thread Bill

On Mar 2, 2008, at 5:35 PM, Ben Trumbull wrote:

My question is, why would changing a property value cause another
property to have its retain count increase?


No idea.  Why don't you run it in gdb and break on the -retain  
method and get some stack traces ?
This works best if the class you're debugging (in this case the  
value window controller) has a custom retain/release method that you  
can break on instead of NSObject's etc.  If it doesn't, you can  
trivially make one by adding a category on it and putting -retain/- 
release/-autorelease methods on it that simply call super.


Good idea.  Here's the stack trace:
#0	0x29aa in -[NSWindowController(MainWindow) retain] at  
MainWindowController.m:35
#1	0x92dfa378 in -[NSManagedObject(_NSInternalMethods)  
_newPropertiesForRetainedTypes:andCopiedTypes:preserveFaults:]

#2  0x92dfa250 in -[NSManagedObject(_NSInternalMethods) _allProperties]
#3	0x92dfa185 in -[NSManagedObjectContext(_NSInternalChangeProcessing)  
_establishEventSnapshotsForObject:]

#4  0x92dfd516 in _PFFastMOCObjectWillChange
#5  0x92dfb4e3 in -[NSManagedObject willChangeValueForKey:]
#6  0x00021a6c in -[Window setOpenAtLaunch:] at Window.m:117

Not sure what to make of it, nor why setting the property openAtLaunch  
increments the retain count for the window controller property.



So by the time the user wants to delete a managed object from the  
list, the window controller could have a high

value and is never released!


This sounds like a hypothetical concern as opposed to an empirically  
observed leak.  Each retainer is obliged to balance itself out  
eventually.  That's not your problem.  Generally speaking, the  
retain count is an implementation dependent value and not really  
meaningful API.


I made the statement because I have an NSLog statement in the window  
controller dealloc method.  It never gets executed unless the retain  
count is 0.


Thanks,
Bill

___

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 [EMAIL PROTECTED]


Re: Subview bounds resizing when frame resizes

2008-03-02 Thread Steve Weller


On Mar 2, 2008, at 4:03 PM, Steve Weller wrote:



I have a custom view with a custom subview. I can't seem t make the  
bounds of the subview stick. When the view changes the subview's  
frame, I want the subview's bounds to stay exactly as I set them the  
first time. The whole point of having this subview is to have a  
separate coordinate system.


I create the subview like this:

// Add page into our view
pageView = [[BTPPPageView alloc] initWithFrame:[self pageFrame]];
	[pageView  
setBounds:NSMakeRect(0,0,pageBoundsSize.width,pageBoundsSize.height)];

[self addSubview:pageView];

and I reposition the subview's frame when the view's frame changes:

[pageView setFrame:[self pageFrame]];

The subview bounds are set correctly at the start, but if I make the  
subview's frame larger, the bounds are scaled larger too. I thought  
from this in the NSView docs that the subview's bounds would stay  
fixed:


If your view does not use a custom bounds rectangle, this method  
also sets your view bounds to match the size of the new frame. You  
specify a custom bounds rectangle by calling setBounds:,  
setBoundsOrigin:, setBoundsRotation:, or setBoundsSize:explicitly.  
Once set, NSView creates an internal transform to convert from frame  
coordinates to bounds coordinates.


I am using setBounds, so why is it not preventing the scaling? My  
view has the Autoresizes subviews flag off. The view is created in  
IB, the subview in code, as above.



Having discovered that all uses of setFrame that I could find that  
handle scaling reset the bounds every time, I changed the code to:


[pageView setFrame:[self pageFrame]];
[pageView  
setBounds:NSMakeRect(0,0,pageBoundsSize.width,pageBoundsSize.height)];


and this achieves what I wanted to do.
___

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 [EMAIL PROTECTED]


NSDocument and control of multiple views

2008-03-02 Thread Steve Weller


I have a document-based application that has a custom view that fills  
much of the content view. In that custom view I want to display a  
"page" like a piece of paper. As the window is scaled, the "page"  
scales. This all works either if I code the page as a part of the  
custom view, or if I set it up as another custom view which is a  
subview of the larger view.


But which is the better approach? I will want to work at two scales at  
all times: the scale on the page and the scale on the custom view.  
Will a subview make that easier?


If I do use a subview, then what should my philosophy be for  
communicating among objects? I *think* that the NSDocument should  
manage both views. If the user resizes the window, that will resize  
the frame of the custom view. That will send a notification to the  
NSDocument which will make the appropriate changes to both views  
(scaling, bounds, whatever). Or is there a better way?


___

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 [EMAIL PROTECTED]


Re: When in the launch cycle does coredata data become available.

2008-03-02 Thread Adam Gerson
Hi mmalc,

Thanks, this does directly address my question. Not exactly sure what
to do with it. I tried calling fetchWithRequest:merge:error: in
awakeFromNib and then trying to access the managed object, but that
didn't work.

Adam


On Sun, Mar 2, 2008 at 9:59 PM, mmalc crawford <[EMAIL PROTECTED]> wrote:
>
>  On Mar 2, 2008, at 6:36 PM, Adam Gerson wrote:
>
>  > NSArray *allServers = [serverLibraryArrayController arrangedObjects];
>  >
>  > This code works just fine with I invoke it with a button click.
>  > However, if I put it in awakeFromNib or ApplicationDidFInishLaunching
>  > it returns nil.
>  >
>  
>    >
>
>  mmalc
>
>
___

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 [EMAIL PROTECTED]


Spotlight importer for records

2008-03-02 Thread Adam P Jenkins
I'd like to make Spotlight index individual records from my  
application, rather than whole files.  Some examples of this are  
Apple's own iCal, Address Book, and Mail.app.  For instance if you  
type in someone's name in the Spotlight search box, in addition to  
files which contain that name, individual Address Book entries that  
match will show up, and selecting one of them will start Address Book  
with that address showing.  I'd like to implement the same sort of  
thing for my app, but the Spotlight Importer Programming Guide just  
shows how to generate metadata for files, but not how to get Spotlight  
to treat individual records as separate files.  Can someone please  
point me in the right direction?


Thank you,
Adam
___

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 [EMAIL PROTECTED]


Re: Problems with ScriptingBridge and iTunes

2008-03-02 Thread Jens Alfke


On 2 Mar '08, at 4:54 AM, Steven Degutis wrote:


I think it's clear why [currentTrack
isKindOfClass:[iTunesFileTrack class]] evaluates to true: in the
previous line, you defined it as such, like this:
iTunesTrack *currentTrack = [iTunes currentTrack];
So obviously it is an iTunesTrack!


No. It could be an instance of a subclass of iTunesTrack, such as (in  
this case) iTunesFileTrack. (That's true of any object-oriented  
language.)



Try this:
iTunesFileTrack *currentTrack = [iTunesFileTrack currentTrack];


That won't even compile. You can't assign an iTunesTrack* to an  
iTunesFileTrack*.


Moreover, since Obj-C is a dynamic language, it's more important what  
the class of the object is at runtime, than what type the pointers are  
defined as at compile time. You can change the type declarations, but  
it won't affect what actual objects you get back at runtime.


—Jens

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 [EMAIL PROTECTED]

Re: NSString and string contains

2008-03-02 Thread Chris Hanson

On Mar 2, 2008, at 12:31 PM, Tom Jones wrote:

I have an NSArray which contains String values and I want to loop  
though it and determine if any of those string contain words I'm  
looking for. I have tried but have been unsuccessful.


Predicates are great for this.  They're a Foundation facility for  
performing queries on collections.


  - (NSArray *)itemsInCollection:(NSArray *)collection containingWord: 
(NSString *)word {
  NSPredicate *containsWordPredicate = [NSPredicate @"SELF  
CONTAINS[cd] %@", word];


  return [collection  
filteredArrayUsingPredicate:containsWordPredicate];

  }

This will return a new collection containing all items in the passed- 
in collection that themselvs contain the given word, and it will do  
the comparison in a case-insensitive and diacritic-insensitive  
fashion.  (Thus if word is @"resume" then @"résumé" and @"Resume"  
would be considered matches.)


In general, any time you can express something as a query rather than  
as explicit iteration, it's a win -- whether you're talking about  
Cocoa or any other framework.  This is because it lets the framework  
itself determine the best way to achieve the results, which can change  
over time.


  -- Chris

___

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 [EMAIL PROTECTED]


Re: NSString and string contains

2008-03-02 Thread Jens Alfke


On 2 Mar '08, at 1:44 PM, Andrew Merenbach wrote:

You probably want to use enumerators and something like the  
following code:


That's debatable. Personally, I hate using NSEnumerator because it's  
slow. (Not only does it create an autoreleased enumerator object, but  
most of the standard collection enumerators copy the collections they  
enumerate over.)


On the other hand, using fast enumeration via the "for...in..." syntax  
in ObjC-2 is a total win. Not only is the syntax clear, but the  
implementation is very efficient (faster than -objectAtIndex, much  
faster than NSEnumerator.)


—Jens

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 [EMAIL PROTECTED]

Re: Spotlight importer for records

2008-03-02 Thread Jens Alfke


On 2 Mar '08, at 10:09 PM, Adam P Jenkins wrote:

I'd like to make Spotlight index individual records from my  
application, rather than whole files.


Spotlight doesn't support that yet. Its unit of granularity is whole  
files.


Some examples of this are Apple's own iCal, Address Book, and  
Mail.app.  For instance if you type in someone's name in the  
Spotlight search box, in addition to files which contain that name,  
individual Address Book entries that match will show up, and  
selecting one of them will start Address Book with that address  
showing.


Mail and AB do that by creating individual files for every record, for  
Spotlight to index. The ones for Address Book are stored in ~/Library/ 
Application Support/Address Book/Metadata/.


You can do the same thing yourself. It doesn't even matter what kind  
of data is in the files, as long as your importer knows how to read  
them. (For example, the AB files aren't vCards, just property lists  
containing the metadata.) Of course you have to keep these files and  
their contents in sync with your real database, which can be a pain.


—Jens

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 [EMAIL PROTECTED]

Re: Subview bounds resizing when frame resizes

2008-03-02 Thread Jens Alfke


On 2 Mar '08, at 4:03 PM, Steve Weller wrote:

The subview bounds are set correctly at the start, but if I make the  
subview's frame larger, the bounds are scaled larger too. I thought  
from this in the NSView docs that the subview's bounds would stay  
fixed:


Nope. Changing a view's frame does not change the scale factor of the  
contents. 99% of the time that's what you want — resizing a button  
shouldn't magnify its text! For the case where you do want the view's  
contents to zoom as you resize it, you'll need to recompute the bounds  
appropriately when the view's frame changes.


—Jens

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 [EMAIL PROTECTED]