Document context

2008-09-19 Thread Apparao Mulpuri
Hi,

I am little confused with the method + (id)elementWithName:(NSString
*)name in NSXMLNode. Is this method will create a new node with in the
current document context or outside of any document context?.

In the Xcode documentation, apple didn't mention about the document context.

- Apparao Mulpuri.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: Document context

2008-09-19 Thread Nathan Kinsinger

On Sep 19, 2008, at 12:05 AM, Apparao Mulpuri wrote:


Hi,

I am little confused with the method + (id)elementWithName:(NSString
*)name in NSXMLNode. Is this method will create a new node with in the
current document context or outside of any document context?.

In the Xcode documentation, apple didn't mention about the document  
context.


- Apparao Mulpuri.


Outside of any document. You will get an NSXMLElement with no parent.

--Nathan



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: fullscreen quicktime across multiple monitors

2008-09-19 Thread Memo Akten

wow that looks perfect thanks..

On 19 Sep 2008, at 05:10, John C. Randolph wrote:



On Sep 17, 2008, at 12:03 PM, Memo Akten wrote:

Hi All, I'd like to create a little app the runs a quicktime movie  
(prores) fullscreen across multiple monitors. I think I can figure  
out the QTKit stuff, but couldn't find upto date documentation on  
going fullscreen. I've found some code snippets to do it, but they  
are all pre-leopard and I have a feeling that its a bit more  
straightforward on leopard (i'm hoping). Can anyone point me in the  
right direction? (or has this already been done?) Its for personal  
use and not distribution so min specs 10.5.5 etc. is fine.


Leopard introduced a new API for this.  See NSView's  
enterFullScreenMode:withOptions: method.


-jcr


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

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

This email sent to [EMAIL PROTECTED]


Re: Core data in private framework.

2008-09-19 Thread Chris Hanson

On Sep 18, 2008, at 8:41 PM, Scott Andrew wrote:

I have a question. We are designing a private frame work to wrap our  
data handling. The framework is using Core Data with an SQL back  
end. However we get errors when loading data if the model file is  
not included in the application and is just in the framework. I  
looked through the docs and couldn't find any help. Are there any  
tricks to having the data model file (.mom) exist in the private  
framework and not in the application's resources? We would like the  
data class to be used across applications by just including the  
framework.


There's nothing special about where a data model is located.

Core Data will use all of the models in your main bundle's Resources  
directory if you use +[NSManagedObjectModel mergedModelFromBundles:]  
and pass it nil.  That's a convenience, you don't have to use that API.


You can just construct a URL containing a file path to the model, e.g.  
using -[NSBundle pathForResource:ofType:] (on your framework's bundle)  
and +[NSURL fileURLWithPath:isDirectory:],  and use - 
[NSManagedObjectModel initWithContentsOfURL:] to initialize a model  
that you +alloc.


  -- 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: fullscreen quicktime across multiple monitors

2008-09-19 Thread Memo Akten
THanks, i'll look in to all that.. though I think for now NSView  
enterFullScreenMode:withOptions: may be quite good


On 19 Sep 2008, at 05:13, Michael Ash wrote:


On Wed, Sep 17, 2008 at 3:03 PM, Memo Akten [EMAIL PROTECTED] wrote:
Hi All, I'd like to create a little app the runs a quicktime movie  
(prores)
fullscreen across multiple monitors. I think I can figure out the  
QTKit
stuff, but couldn't find upto date documentation on going  
fullscreen. I've
found some code snippets to do it, but they are all pre-leopard and  
I have a
feeling that its a bit more straightforward on leopard (i'm  
hoping). Can
anyone point me in the right direction? (or has this already been  
done?) Its
for personal use and not distribution so min specs 10.5.5 etc. is  
fine.


Fullscreen just means that you cover the entire screen with your
window. In this case, covering all screens. There's no need for a
special API (although special APIs are available), just make a
standard NSWindow, set its frame to cover all the screens, make sure
that it contains what you want, and you're good.

For more specific guidance, NSScreen can be used to find out where all
the screens are, NSBorderlessWindowMask will give you a window with no
title bar or other distracting decorations, and
NSApplicationDidChangeScreenParametersNotification will tell you if
the configuration of the screens changed so you can re-position your
window.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

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

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]


UIElement app doesn't come to front

2008-09-19 Thread Memo Akten
I want to create a very simple little app that launches a window at  
startup, and then runs in the background with no dock and menu.


I've created the app as a standard cocoa app, extending NSApplication   
overriding init (set delegate to self) and  
applicationDidFinishLaunching to setup a timer (and  
applicationWillTerminate to cleanup) - I've also set 'Application is  
agent' to true in Info.plist.


When I start the app from Xcode, my window opens, when I close it the  
window dissappears and my app carries on running in the background as  
expected.


But when i run the app from finder, my window appears at the very back  
of all other windows so isn't visible, how can I fix this?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: Differences between -isEqual: and -isEqualTo:?

2008-09-19 Thread Keith Duncan

you [...] aren't allowed to mutate objects that are in collections


Where is that documented? I've been doing this without consideration  
and nothing's blown up yet.


How is a method to know if an object it's been passed is in a  
collection? Equally how are you to know if a method is going to mutate  
an object's properties?


You simply can't determine either situation conclusively. If this is  
so fundamental, why haven't I been tripped up by it?


Keith Duncan
[EMAIL PROTECTED], 33software.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]


Deleting Alias

2008-09-19 Thread Glover,David
Hi,

 

I've tried using removeFileAtPath to delete an alias in the users home
folder, but this doesn't work - it deletes any other file, just not
aliases.

 

I can't seem to find another method that will do the job.  Any help or
advice to resolve this would be greatly appreciated.

 

Kind Regards

Dave

 


Promethean Limited is a company registered in England and Wales with company 
number 1308938 and VAT number GB 572 2599 18
__

Promethean Ltd and or associated and or subsidiary companies :

The views expressed in this communication may not necessarily be 
the views held by Promethean Ltd and or associated and or subsidiary companies.

This e-mail is for the exclusive use of the addressee(s). Unauthorised 
disclosure, copying or distribution is prohibited.

This e-mail message has been swept for the presence of computer viruses.

Promethean Ltd and or associated and or subsidiary companies accepts no 
liability for any loss resulting from this email transmission.

Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire, BB1 
5TH, UK. Please update your records accordingly. Thank you!



*
This email has been checked by the e-Sweeper Service
*

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: UIElement app doesn't come to front

2008-09-19 Thread Fabian
Try [NSApp activateIgnoringOtherApps:YES];

HTH.

On Fri, Sep 19, 2008 at 12:28 PM, Memo Akten [EMAIL PROTECTED] wrote:
 I want to create a very simple little app that launches a window at startup,
 and then runs in the background with no dock and menu.

 I've created the app as a standard cocoa app, extending NSApplication
  overriding init (set delegate to self) and applicationDidFinishLaunching to
 setup a timer (and applicationWillTerminate to cleanup) - I've also set
 'Application is agent' to true in Info.plist.

 When I start the app from Xcode, my window opens, when I close it the window
 dissappears and my app carries on running in the background as expected.

 But when i run the app from finder, my window appears at the very back of
 all other windows so isn't visible, how can I fix this?
 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/slasktrattenator%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: UIElement app doesn't come to front

2008-09-19 Thread Memo Akten

thanks, that did it...


On 19 Sep 2008, at 15:18, Fabian wrote:


Try [NSApp activateIgnoringOtherApps:YES];

HTH.

On Fri, Sep 19, 2008 at 12:28 PM, Memo Akten [EMAIL PROTECTED] wrote:
I want to create a very simple little app that launches a window at  
startup,

and then runs in the background with no dock and menu.

I've created the app as a standard cocoa app, extending NSApplication
overriding init (set delegate to self) and  
applicationDidFinishLaunching to
setup a timer (and applicationWillTerminate to cleanup) - I've also  
set

'Application is agent' to true in Info.plist.

When I start the app from Xcode, my window opens, when I close it  
the window
dissappears and my app carries on running in the background as  
expected.


But when i run the app from finder, my window appears at the very  
back of

all other windows so isn't visible, how can I fix this?
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/slasktrattenator%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 hide disclosure triangle in NSOutlineView [10.5]?

2008-09-19 Thread Marc Respass

Hi All,

I have an outline view connected to a tree controller and I want to  
hide the disclosure triangle. I know that there is a data source  
delegate method, - (BOOL)outlineView:(NSOutlineView *)outlineView  
isItemExpandable:(id)item, but when I make my controller the data  
source of the outline view and implement that method, it is never  
called. I am running in Leopard and I suspect that because I'm using  
bindings that the tree controller is the data source.


Any tips on how to hide the disclosure triangle but still allow  
children?


Thanks a lot
Marc
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: How to hide disclosure triangle in NSOutlineView [10.5]?

2008-09-19 Thread Corbin Dunn


On Sep 19, 2008, at 7:58 AM, Marc Respass wrote:


Hi All,

I have an outline view connected to a tree controller and I want to  
hide the disclosure triangle. I know that there is a data source  
delegate method, - (BOOL)outlineView:(NSOutlineView *)outlineView  
isItemExpandable:(id)item, but when I make my controller the data  
source of the outline view and implement that method, it is never  
called. I am running in Leopard and I suspect that because I'm using  
bindings that the tree controller is the data source.


Yes -- it is because you are using bindings.




Any tips on how to hide the disclosure triangle but still allow  
children?


Yes! it's very easy.

Here's a good section to read:

http://developer.apple.com/releasenotes/Cocoa/AppKit.html#NSTableView

And the part you want:

To not show a disclosure triangle, override - 
frameOfOutlineCellAtRow: and return an empty rect.



corbin
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

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

This email sent to [EMAIL PROTECTED]


NSTextView not always accepting a Favorite style from NSFontPanel

2008-09-19 Thread Russell Finn
I am struggling with a puzzling problem involving an NSTextView and
the Favorites list in the NSFontPanel.  I'm hoping someone on the list
has seen something like this before and/or can offer any pointers.

My program is a document-based application with a main document window
that includes an NSTextView.  [Technically it is a subclass of
NSTextView, but I have substituted an actual NSTextView without
changing the behavior.]  I load some rich text from an RTF file into
my NSTextView, and select some text whose font has the bold or
underlined trait (e.g., Helvetica-Bold).  I open the font panel and
click on a style from the Favorites list (e.g. Impact).  If I do this,
the style of the text in the NSTextView does *not* appear to change.
If, however, I initially select text that does *not* have the bold or
underlined trait (e.g., plain Helvetica), the selected style *is*
correctly applied to my text as well.

If I perform the same steps in TextEdit, it behaves as I expect: the
text font is replaced by the selected style from the font panel,
regardless of the original font of the text.

I used some method swizzling to break into the changeFont: method of
the text view and insert some additional debugging code.  I am able to
get the selected text's NSFont and send it directly to the
NSFontManager's convertFont: method.  If the selected text's NSFont is
Helvetica-Bold, I get Helvetica-Bold back; if it is plain Helvetica, I
get Impact back.  If I manually strip the bold trait from the
Helvetica-Bold font, giving me a plain Helvetica, and send *that* to
the NSFontManager, I still get Helvetica-Bold back.

I see analogous behavior if I select italic text, in that I get
Helvetica-Oblique back from the NSFontManager.  I also see the same
thing if I send the font to the font panel for conversion (via
panelConvertFont:).  It is as if I'm getting back the font panel's
represention of the currently selected font in my text, instead of the
font I click in the Favorites list -- but only if that font has a bold
or italic trait.  Finally, selecting an item from the Recently Used
list produces the same anamolous behavior as the Favorites list.

I am at a loss to explain this.  Clearly there must be some difference
in the context of my program, compared to TextEdit, but I have been
unable to determine what that is.  I inherited this code base from
another developer, and there are some oddities in the coding style,
but I have not found anything relating to the font panel or text
system that would explain this difference in behavior.  (My program is
normally built against the 10.3.9 SDK, but changing it to the 10.5 SDK
to match TextEdit does not alter the behavior either.)

Has anyone seen this kind of behavior before, or has any kind of
insight into where I might look?  I'm running out of ideas and any
suggestions would be appreciated.

Thanks -- Russell
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: Weird Error

2008-09-19 Thread Jim Correia

On Sep 19, 2008, at 11:18 AM, development2 wrote:


Ok I hope someone can help me. I need to get this working.

Here is what I am doing. I have a class called Object, it is set up  
like this:


Object is the root object defined by the Objective-C language.  
(NSObject is typically the root object used by the Cocoa frameworks.)


/usr/include/objc/Object.h

Don't redefine it. Use a different name for your class.

Jim

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: Weird Error

2008-09-19 Thread Charles Steinman
--- On Fri, 9/19/08, development2 [EMAIL PROTECTED] wrote:

   // in here we need to gets the info out of the
 dictioanary and into  
 the object

Why would you bother including your entire header file and boilerplate code and 
then edit out the part where the error occurs? That's just...backwards.

Anyway, it sounds like you just need to check for nil.

Cheers,
Chuck


  
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: Deleting Alias

2008-09-19 Thread Glover,David
Hi, just in case anybody else notices similar behaviour - I called
removeFileAtPath if an fileExistsAtPath check on the alias evaluated to
true - BUT fileExistsAtPath method only returns true on an alias if the
original file / app is present.  The removeFileAtPath method on its own
will quite happily delete an alias whether the original file is present
or not AFAIK.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
om] On Behalf Of Glover,David
Sent: 19 September 2008 11:36
To: Cocoa Development
Subject: Deleting Alias

Hi,

 

I've tried using removeFileAtPath to delete an alias in the users home
folder, but this doesn't work - it deletes any other file, just not
aliases.

 

I can't seem to find another method that will do the job.  Any help or
advice to resolve this would be greatly appreciated.

 

Kind Regards

Dave

 


Promethean Limited is a company registered in England and Wales with
company number 1308938 and VAT number GB 572 2599 18
__

Promethean Ltd and or associated and or subsidiary companies :

The views expressed in this communication may not necessarily be 
the views held by Promethean Ltd and or associated and or subsidiary
companies.

This e-mail is for the exclusive use of the addressee(s). Unauthorised 
disclosure, copying or distribution is prohibited.

This e-mail message has been swept for the presence of computer viruses.

Promethean Ltd and or associated and or subsidiary companies accepts no
liability for any loss resulting from this email transmission.

Promethean, Promethean House, Lower Philips Road, Blackburn, Lancashire,
BB1 5TH, UK. Please update your records accordingly. Thank you!



*
This email has been checked by the e-Sweeper Service
*

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/david.glover%40promethe
anworld.com

This email sent to [EMAIL PROTECTED]


*
This email has been checked by the e-Sweeper Service
*

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: fullscreen quicktime across multiple monitors

2008-09-19 Thread Sean McBride
It does, doesn't it.  However, it has lots of little problems, and is
only really useful for the simplest of cases.  Search the list archives
for enterFullScreenMode.

On 9/19/08 9:42 AM, Memo Akten said:

wow that looks perfect thanks..

On 19 Sep 2008, at 05:10, John C. Randolph wrote:


 On Sep 17, 2008, at 12:03 PM, Memo Akten wrote:

 Hi All, I'd like to create a little app the runs a quicktime movie
 (prores) fullscreen across multiple monitors. I think I can figure
 out the QTKit stuff, but couldn't find upto date documentation on
 going fullscreen. I've found some code snippets to do it, but they
 are all pre-leopard and I have a feeling that its a bit more
 straightforward on leopard (i'm hoping). Can anyone point me in the
 right direction? (or has this already been done?) Its for personal
 use and not distribution so min specs 10.5.5 etc. is fine.

 Leopard introduced a new API for this.  See NSView's
 enterFullScreenMode:withOptions: method.

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

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

This email sent to [EMAIL PROTECTED]


NSFetchRequest

2008-09-19 Thread chaitanya pandit

Hi, List,
I have a core data model with 4 entities (viz. Person,Company,Bank and  
Address) each entity has an attribute ID which is of kind NSString.
Now, what i want to do is i already have an ID and i want to find a  
managedObject with matching ID.
What i do right now is i create an NSFetchRequest for each entity type  
(Person,Bank...) and execute each of them. So i end up executing 4  
fetch requests, one for  each entity.
Is there any way to create a single NSFetchRequest which will search  
for the ID in all the entities?


Thanks,
Chaitanya
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: How to hide disclosure triangle in NSOutlineView [10.5]?

2008-09-19 Thread chaitanya pandit
What you can do is create an image which has nothing i.e is  
transparent and use the following method to set it as the image of  
disclosure triangle


- (void)outlineView:(NSOutlineView *)outlineView  
willDisplayOutlineCell:(id)cell forTableColumn:(NSTableColumn  
*)tableColumn item:(id)item

{
[cell setImage:[NSImage imageNamed:@myBlankImage.png]];
}

hth,
Chaitanya

On 19-Sep-08, at 8:28 PM, Marc Respass wrote:


Hi All,

I have an outline view connected to a tree controller and I want to  
hide the disclosure triangle. I know that there is a data source  
delegate method, - (BOOL)outlineView:(NSOutlineView *)outlineView  
isItemExpandable:(id)item, but when I make my controller the data  
source of the outline view and implement that method, it is never  
called. I am running in Leopard and I suspect that because I'm using  
bindings that the tree controller is the data source.


Any tips on how to hide the disclosure triangle but still allow  
children?


Thanks a lot
Marc
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/chaitanya%40expersis.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]


Core Data adding new instance - creating relationship to existing instance

2008-09-19 Thread Amy Heavey
I'm trying to add new instances of some entities, I've got it adding  
new objects, and I can create new relationships to new related  
objects, but I can't work out how to connect a new instance to an  
existing instance of an entity,


eg

I have items with relationship to upcs and categories. I can add the  
new item, and set all the attributes, and new relationships to the  
new upcs that are also created, but I cannot create the new  
relationship to an existing category. The Category Entity has an  
attribute called name that I want to match to an NSString


I am assuming that I would actually set the relationship in the usual  
manner:


NSManagedObject *newItem = [NSEntityDescription
insertNewObjectForEntityForName:@Item
 inManagedObjectContext:moc];



NSPredicate *catFind = [NSPredicate predicateWithFormat:@name like % 
@,categoryString];


NSFetchRequest *fetch=[[NSFetchRequest alloc] init];
		[fetch setEntity:[NSEntityDescription entityForName:@Category  
inManagedObjectContext:moc]];

[fetch setPredicate:catFind];
NSArray *category = [moc executeFetchRequest:fetch error:nil];  

[newItem setValue:[category objectAtIndex:0] forKey:@Category];

The problem is actually selecting the category, I have tried all  
manner of things, and I thought I needed a fetchRequest, but it just  
throws an error:


-[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)

because there is nothing in the array?

I'm aiming at 10.4 and using XCode 2.4.1

Can anyone help me?

Many Thanks

Amy


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: Drawing an NSImage in a CALayer

2008-09-19 Thread Matt Long

Hey Brad,

I re-read my message and realized I was a bit condescending in my  
comments. Not sure why I was over-stating things so much. I didn't  
think I was in a bad mood, but maybe I was. ;-) Anyhow, sorry about  
that.


I'm interested in what you are doing here so I went ahead and wrote a  
bit of code. Take a look at my demo project here and let me know if  
this helps.


http://www.matthew-long.com/download/ImageButtonLayer.zip

-Matt

p.s. I would defer to David Duncan on the CGImageRef creation  
overhead. I'm sure he's right. I just didn't have the time to try to  
get his code to work. ;-)




On Sep 18, 2008, at 5:00 PM, Brad Gibbs wrote:



On Sep 18, 2008, at 3:18 PM, Matt Long wrote:


You've got some fundamental issues here.


That doesn't surprise me...




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: How make a cocoa lib wich create a window ?

2008-09-19 Thread Ken Thomases

On Sep 18, 2008, at 11:38 PM, rouanet brice wrote:

I work on a projetc where the executable haven't GUI but I can  
launch somme

gui window with plugins.

test - no gui application
 -plugin
   -triangle - this plugin display a triangle in a cocoa window
   -rectangle - this plugin display a rectangle in a cocoa window

All plugins works in standolone applications, but when I launch  
test, I cant

see the window.


You need a couple of things.  First, you will need to use  
TransformProcessType to turn your non-GUI process into a GUI  
process.  Second, you will need to initialize an NSApplication and  
its connection to the window server.  Read the class overview for  
NSApplication.  You will also need to run the event loop somehow.   
Normally, this would be done using -[NSApplication run], but you may  
be able to get away with just -[NSApplication runModalForWindow:].


Cheers,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

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

This email sent to [EMAIL PROTECTED]


Re: Weird Error

2008-09-19 Thread development2

Yep I figured it out. That was it. Just a stupid on my part.

Thanks.
On Sep 19, 2008, at 9:31 AM, Jim Correia wrote:


On Sep 19, 2008, at 11:18 AM, development2 wrote:


Ok I hope someone can help me. I need to get this working.

Here is what I am doing. I have a class called Object, it is set up  
like this:


Object is the root object defined by the Objective-C language.  
(NSObject is typically the root object used by the Cocoa frameworks.)


/usr/include/objc/Object.h

Don't redefine it. Use a different name for your class.

Jim




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: Drawing an NSImage in a CALayer

2008-09-19 Thread David Duncan

On Sep 19, 2008, at 10:48 AM, Matt Long wrote:

p.s. I would defer to David Duncan on the CGImageRef creation  
overhead. I'm sure he's right. I just didn't have the time to try to  
get his code to work. ;-)



I forgot to set the current context :). More complete code here,  
although this doesn't take the real resolution of the image into  
account (-size returns a value in points, not pixels).


-(CGImageRef)nsImageToCGImageRef:(NSImage*)nsimage;
{
NSSize imageSize = [nsimage size];
	CGColorSpaceRef genericRGB =  
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
	CGContextRef context = CGBitmapContextCreate(NULL, imageSize.width,  
imageSize.height, 8, 0, genericRGB, kCGImageAlphaPremultipliedFirst);
	NSGraphicsContext *nsGraphicsContext = [NSGraphicsContext  
graphicsContextWithGraphicsPort:context flipped:NO];

[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:nsGraphicsContext];
[[NSColor yellowColor] setFill];
NSRectFill(NSMakeRect(0.0, 0.0, imageSize.width, imageSize.height));
	[nsimage drawAtPoint:NSZeroPoint fromRect:NSZeroRect  
operation:NSCompositeCopy fraction:1.0];

[NSGraphicsContext setCurrentContext:nsGraphicsContext];
CGImageRef image = CGBitmapContextCreateImage(context);
CFRelease(context);
return image;
}

--
David Duncan
Apple DTS Animation and Printing

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: Differences between -isEqual: and -isEqualTo:?

2008-09-19 Thread Nate Weaver
This is the gist of it, I think. NSArray and NSDictionary should be  
safe to store mutable objects, since they use an index or a key for  
storage position, and not the object (the value) itself.


So (as I understand it): You *are* allowed to mutate objects in  
collections, but only if the object state doesn't determine storage  
position in the collection (NSArray/NSDictionary yes, NSSet no), or  
you can be sure the object's hash will not change (it probably will).


(I may be repeating what's been said, but maybe it'll be a bit more  
clear?)


On Sep 19, 2008, at 9:14 AM, Jim Correia wrote:


On Sep 19, 2008, at 6:32 AM, Keith Duncan wrote:


If this is so fundamental, why haven't I been tripped up by it?


It is an edge case, but one worth knowing about. You have to be  
storing mutable objects in a collection whose internal storage  
position depends on the objects hash code.


Jim

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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]


File I/O

2008-09-19 Thread Jordon Hirshon
How can I read a file a line at a time (i.e. getline)?  I'm trying to do this 
in  a Cocoa Framework.

Thanks,
Jordon


  
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: File I/O

2008-09-19 Thread Nick Zitzmann


On Sep 19, 2008, at 3:15 PM, Jordon Hirshon wrote:

How can I read a file a line at a time (i.e. getline)?  I'm trying  
to do this in  a Cocoa Framework.



Try using NSFileHandle to read a file until a line feed is  
encountered. There's no built-in method of stopping at a character,  
but you could always read it in byte by byte.


Nick Zitzmann
http://www.chronosnet.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]


Re: File I/O

2008-09-19 Thread Shawn Erickson
On Fri, Sep 19, 2008 at 2:15 PM, Jordon Hirshon [EMAIL PROTECTED] wrote:
 How can I read a file a line at a time (i.e. getline)?  I'm trying to do this 
 in  a Cocoa Framework.

line in what sense? is this a text(ish) file?

Anyway look at -[NSString getLineStart:end:contentsEnd:forRange:] and
possibly NSScanner.

-Shawn
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

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

This email sent to [EMAIL PROTECTED]


Re: File I/O

2008-09-19 Thread Jason Coco


On Sep 19, 2008, at 17:20 , Nick Zitzmann wrote:



On Sep 19, 2008, at 3:15 PM, Jordon Hirshon wrote:

How can I read a file a line at a time (i.e. getline)?  I'm trying  
to do this in  a Cocoa Framework.



Try using NSFileHandle to read a file until a line feed is  
encountered. There's no built-in method of stopping at a character,  
but you could always read it in byte by byte.


Or you could read the file into a string and split it with \n,  
although Nick's method is probably more efficient:


NSError *error;
// use the proper encoding if it's not UTF-8
NSString *string = [[NSString alloc] initWithContentsOfFile:path  
encoding:NSUTF8StringEncoding error:error];

if( !string ) { /* do something with the error */ }

NSArray *lines = [[string componentsSeparatedByString:@\n]  
retain];	// assuming line terminator is \n for this file

[string release];

for( NSString *line in lines ) {
// process each line
}
[lines release];



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]

[Moderator] Re: Games for iPhone

2008-09-19 Thread Scott Anguish


On 18-Sep-08, at 6:36 PM, D.K. Johnston wrote:

I've written a couple of cute little memory games. If anyone is  
interested in creating an iPhone interface for them, please contact  
me off-list.




Two issues.

First, the iPhone isn't to be discussed here. Period.

Second, do not crosspost cocoa-dev with any other list.

thanks

scott
[moderator]




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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]


Constant NSArray Count

2008-09-19 Thread Alex Mills

Hey,

I'm rather new to cocoa (and programming in general) and I'm working  
on a core data project that uses a tab view to display different  
attributes of an entry. I'm trying to code it so that if no items are  
selected in the list it will display a tab, otherwise display a  
different tab. I have this working as an IBAction but I want it to run  
all the time so that it will control the tabs whenever the selection  
count of the Array changes, how can I do this?


This is the IBAction that I want to run all the time:

-(IBAction)checkCount: sender;
{
NSArray *selectedObjects = [propertyTableController selectedObjects];
NSUInteger count = [selectedObjects count];
if (count == 0)
{
[newTabView selectTabViewItemWithIdentifier:@2];
}
else
{
[newTabView selectTabViewItemWithIdentifier:@1];
}   
return;
}

I also want a similar setup to count the number of items in the array,  
so that if the user hasn't created anything 'Tab 1' will displayed, if  
there is at least one created item 'Tab 2' will be displayed. If you  
guys know of a better way to do the above procedure please let me know.


Cheers
Alex Mills


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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]


Text View with fixed width

2008-09-19 Thread Aleksandro Eterverda
Hi

I'm new to this list and I'm completly new to Cocoa. I'm creating my
first app but I stuck with the following.

I have an instance of NSTextView (created with Interface Builder) in
an instance of NSScrollView. I want text to be layed out in area of
fixed width (length should be as it is - unlimited). And I want this
area to stay in the middle of scroll view. For example 500 px. wide,
250 px. from right and 250 px. from left for 1000 px. wide scroll
view. And I also would like to have text justified in that 500 px.

If you ever tried WriteRoom you'll know what I mean.

I tried to call [textView setTextConrainerInset:] but it's not what I
want. I don't like to control insets by myself when resizing window (I
often resize it programmatically with animation especially in my full
screen implementation).

Is it possible? Could you please help me with some snippet or something alike?

Thank you.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: async NSOperation and NSOperationQueue

2008-09-19 Thread Jason Coco


On Sep 19, 2008, at 18:27 , Michael Ash wrote:

On Fri, Sep 19, 2008 at 2:41 PM, John Love [EMAIL PROTECTED]  
wrote:

Michael Ash wrote:




Has it occurred to you that waiting for the operation to finish is
rather at odds with the idea of trying to run it asynchronously to
keep your program responsive?




Absolutely, but if the Thread is running in the background, it really
shouldn't matter to the main Thread of the app.  While calculations  
of a
document are buzzing away in the background, I could be doing other  
things,
e.g., opening other docs to get their calculations going.  But, I  
cannot get

back control until after the first document's calculations are done.


I'm confused. I thought that the call to [theQueue
waitUntilAllOperationsAreFinished] was being made on the main thread.
If you're already spawning a second thread for those calls, why bother
with the NSOperationQueue at all?


That's how I read it too...

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: Constant NSArray Count

2008-09-19 Thread Nick Zitzmann


On Sep 19, 2008, at 9:15 AM, Alex Mills wrote:

I have this working as an IBAction but I want it to run all the time  
so that it will control the tabs whenever the selection count of the  
Array changes, how can I do this?



You can use KVO to call a method when the selectedObjects value  
changes. Check the KVO documentation and the archives for more details.


Nick Zitzmann
http://www.chronosnet.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]


[MEET] LA CocoaHeads : Thursday 9/25 7:30pm

2008-09-19 Thread Rob Ross

Hey LA CocoaHeads.

Next week we continue our study group meeting for the Aaron Hillegass  
book Cocoa Programming for Mac OS X, 3rd Edition.


http://search.barnesandnoble.com/Cocoa-Programming-for-Mac-OS-X/Aaron-Hillegass/e/9780321503619/?itm=1

We'll be covering chapters 7-9. Please jot down any question you come  
up with during your reading.


We meet at the offices of E! Entertainment at 7:30pm.

Our meeting location is

5750 Wilshire Blvd
Los Angeles, CA 90036.

Here's a google map of the location:

http://www.google.com/maps?f=qhl=enq=5750+Wilshire+Blvd,+Los+Angeles+CA+90036ie=UTF8z=15om=1iwloc=addr

Free street parking is available. I'd suggest trying Masselin Ave,  
which is one block East of Courtyard Place.


We meet near the lobby of the West building at 5750 Wilshire Blvd, on  
the West side of Courtyard Place. There are picknick tables in front  
of the lobby and we'll gather there starting at 7:20pm. From there we  
go inside and up to conference room 3A at around 7:45pm .


If you arrive late, please ask the building security personnel in the  
lobby to direct you to the E! Security office, and they will be able  
to contact the group in conference room 3A and send someone down to  
meet you.



Rob Ross, Lead Software Engineer
E! Networks

---
Beware of he who would deny you access to information, for in his  
heart he dreams himself your master. -- Commissioner Pravin Lal

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: NSOperationQueue

2008-09-19 Thread Quincey Morris

On Sep 19, 2008, at 08:15, John Love wrote:


9) Its -startCalculation looks like:
- (void) startCalculation { 
int row;
// itsCalcStatus = kNoError;   // set by -init  
for (row=1; row  1; row++) {
if (itsCalcStatus == kSpreadsheetStopped)  break;
if (itsCalcStatus != kNoError)  break;

itsCalcStatus = kSpreadsheetCalculating;
[self startOperation];   // start new thread
// if running in background, this will have no effect:
[itsQueue waitUntilAllOperationsAreFinished];
}


This method is being executed on the main thread (unless I missed  
something). '[self startOperation]' causes (eventually) a new thread  
to be created, executing the 'calculateWorksheetRow' method. But  
'startCalculation' continues in the main thread and reaches '[itsQueue  
waitUntilAllOperationsAreFinished]'. At that point, it blocks waiting  
for the background operations to finish. So your main thread has  
stopped dead, and of course your application becomes unresponsive,  
until the background threads all complete.


I think the simplest way to achieve what you want is to remove  
'[itsQueue waitUntilAllOperationsAreFinished]' completely, move the  
rest of 'startCalculation' to a new method, and create an extra  
operation that runs this new method. Use [NSOperation addDependency:]  
to make this extra operation dependent on all the calculation  
operations, then add the extra operation to your queue.


Or something like that.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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: NSInvocation

2008-09-19 Thread Michael Ash
On Wed, Sep 10, 2008 at 1:44 PM, Michael Ash [EMAIL PROTECTED] wrote:
 But if you use it to call a method which returns a struct, then it
 crashes and burns. It doesn't even throw an exception, it just
 segfaults.

 I've filed this as a bug as rdar://6210060. It really should work, but
 it doesn't.

I just thought I would follow up on this, as I got a reply to my bug
today. Basically, the reply says that this problem is known, it's not
possible to fix it, but if you use class_getMethodImplementation() and
class_getMethodImplementation_stret() instead, then the problem goes
away. So if you have a pressing need for forwarded struct-returning
methods to work when doing this, use those.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

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

This email sent to [EMAIL PROTECTED]


Re: NSOperationQueue

2008-09-19 Thread Mike Fischer

Am 20.09.2008 um 00:51 schrieb John Love [EMAIL PROTECTED]:


No sooner do I say Solved that I determine Not Solved.

I am no longer crashing in part due to the fact that I've removed
NSApplescript from the thread; however, the evidence is still
insurmountable that the calculation is not running in a background
Thread, but in the main thread.  Because it's in the foreground, I
lose control of my application until the Thread finishes.


I'm betting it is not running at all, see below.



If you have already answered my problem, I apologize in advance for
the noise.

Some of this repeats what I've already posted, but I am going big-time
overboard in an attempt to be complete:

By way of background:
1) a IBOutlet of MyDocument = MyDocController
2) a IBOutlet of MyDocController = MyCalculationController

To continue:
3) In MyDocument's windowControllerDidLoadNib I call MyDocController's
MakeNewFile to which I pass the (NSURL*)theFile which is the file I
just double-clicked on Cocoa's built-in open dialog.  (If theFile =
nil) then I open up a blank document)  If theFile is not nil, then I
call MyDocController's startCalculation.
4) MyDocController's startCalculation calls MyCalculationController's
startCalculation.

Now, the threading fun begins all within MyCalculationController:
6) Its Interface looks like:
@interface MyCalculationController:NSObject {
NSOperationQueue  *itsQueue;
NSInvocationOperation *itsOp;


It seems kind of pointless to allow only a single operation for the  
queue.




int   itsCalcStatus;
}

7) Its -init looks like:
- (id) init {   
if (self = [super init]) {
itsCalcStatus = kNoError;  // an enumerated constant
itsQueue  = [[NSOperationQueue alloc] init];
itsOp = nil;
}   
return self;
}

8) Its -dealloc looks like:
- (void) dealloc {
[itsQueue release];
// [itsOp release];   // each Operation released after it is finished
[super dealloc];
}

9) Its -startCalculation looks like:
- (void) startCalculation { 
int row;
// itsCalcStatus = kNoError;   // set by -init  
for (row=1; row  1; row++) {
if (itsCalcStatus == kSpreadsheetStopped)  break;
if (itsCalcStatus != kNoError)  break;

itsCalcStatus = kSpreadsheetCalculating;
[self startOperation];   // start new thread
// if running in background, this will have no effect:
[itsQueue waitUntilAllOperationsAreFinished];


See the documentation:
waitUntilAllOperationsAreFinished
Blocks the current thread until all of the receiver’s queued and  
executing operations finish executing.


http://developer.apple.com/documentation/Cocoa/Reference/ 
NSOperationQueue_class/Reference/Reference.html#//apple_ref/occ/instm/ 
NSOperationQueue/waitUntilAllOperationsAreFinished


So if -startCalculation is executed on the main thread (which seems  
to be the case AFAICT) then the main thread will block until the  
operation is done. In that case the whole concept of using  
NSOperation becomes just so much overhead without any practical benefit.


I would expect you to queue an NSOperation in the loop and if you  
really need to wait until all of them are done executing then you  
could wait after the loop. Note though, that you would still be  
blocking the main thread. But at least you would be taking advantage  
of NSOperationQueues ability to schedule multiple operations in  
parallel depending on available system resources.


But maybe even that will not be necessary. If it isn't then you need  
to restructure your code to continue after some sort of notification  
that all of your operations are done. You could keep a counter which  
is initialized to the number of rows and decremented whenever an  
operation is done. Make sure to access this counter only with proper  
locks in place (see @synchronized() etc.). When the counter reaches 0  
then fire a notification to your main thread or trigger the next step  
in your workflow by calling one of the performSelectorOnMainThread:  
methods. Or in keeping with the NSOperation model you could fire off  
a special NSOperation which watches your counter periodically until  
the counter reaches 0 and have the rest of your workflow in another  
NSOperation that is dependent on this operation.




BTW: I don't see how you are communicating what the (background)  
operation is actually supposed to do. The local variable row is not  
accessible to the code running in the NSOperation.





}

// After the for-loop completes, itsCalcStatus =
// kSpreadsheetCalculating, kSpreadsheetStopped, kNoExcelApp, or
kNoWorkbook
// So ...
if (itsCalcStatus == kSpreadsheetCalculating) {
// no errors
[self finishCalculation];
 

Re: Modal dialog without NSApplication

2008-09-19 Thread Rob Keniger


On 19/09/2008, at 2:41 AM, brodhage wrote:

I allready do. And then I call this function (within subclass of  
NSWindowController):


- (void)showModalDialog
{
NSApplication *_app;
NSWindow *_window;

[self showWindow:nil];
_app = [NSApplication sharedApplication];
_window = [self window];
[_app runModalForWindow:_window];
}

The modal dialog (displayed this way) blocks everything - it is not  
possible to close the modal dialog, hit any button or something else.


For me it seems that the NSApplication:: runModalForWindow blocks all.
So what I am searching for is to display the modal dialog without  
NSApplication.



I am successfully using modal Cocoa windows in a plugin inside a  
Carbon application.


Others have already spoken about the need for NSApplicationLoad() and  
setting up an autorelease pool, you definitely have to do both these  
things.


To display the window I do this:

//show the window
[window makeKeyAndOrderFront:nil];

//start a modal session and wait for a response
NSModalSession session = [NSApp beginModalSessionForWindow:window];
NSInteger response;
for (;;) {
response=[NSApp runModalSession:session];
if (response != NSRunContinuesResponse)
break;
//
}

//when the user exits the window, hide the window
[NSApp endModalSession:session];
[window close];

You can hook up your OK/cancel buttons something like this:

-(IBAction) ok: (id)sender
{
[NSApp stopModal];
}
-(IBAction) cancel: (id)sender
{
[NSApp abortModal];
}

You can then test for the return value of the NSModalSession and do  
whatever you want with the results.


--
Rob Keniger



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
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]