Mixing ObjC and C++ STL on same ObjC source file

2008-09-12 Thread Daniel Luis dos Santos

Hello !

I have an objective C class and want to call a method on a class in C+ 
+. As argument to the C++ class is a map instance of the STL.

The ObjC class definition is on a file with a mm extension.

I have std::map *var as a member variable of the ObjC class. When I  
compile the code there is an error saying :


/Users/dlsa/code/Finema/trunk/LiquidSurfaces/src/CVDisplayPipeline.h: 
20: error: using-declaration for non-member at class scope


How do I do 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: Mixing ObjC and C++ STL on same ObjC source file

2008-09-12 Thread matt . gough


On 12 Sep 2008, at 10:17, Daniel Luis dos Santos wrote:


Hello !

I have an objective C class and want to call a method on a class in C 
++. As argument to the C++ class is a map instance of the STL.

The ObjC class definition is on a file with a mm extension.

I have std::map *var as a member variable of the ObjC class. When I  
compile the code there is an error saying :


/Users/dlsa/code/Finema/trunk/LiquidSurfaces/src/CVDisplayPipeline.h: 
20: error: using-declaration for non-member at class scope


How do I do this ?
___



Does this happen when you compile CVDisplayPipeline.mm, or when you  
compile another file which might only be a .m file? If it is the  
latter, then that would be your problem since you are no longer  
compiling Obj-C++.


If it is in CVDisplayPipeline.mm then It could just be that you aren't  
including the right header file in CVDisplayPipeline.h ( I think).


If you do have to include your .h file in other .m files, you can  
workaround the problem of having pointers to C++ classes like so:


#if defined(__cplusplus)
#include 
typedef std::map* std_mapPtr;
#else
typedef void* std_mapPtr;
#endif

@interface MyClass: NSObject
{
std_mapPtr mMap;
}

-(std_mapPtr) map;

-(void) setMap: (std_mapPtr) aMap;
@end;

Matt
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Mixing ObjC and C++ STL on same ObjC source file

2008-09-12 Thread Daniel Luis dos Santos
The problem was that in CVDisplayPipeline.h I was declaring the map as  
a return type of a method, but without specifying the template types  
(caused by my relative ignorance of C++).


Now I have another problem, which I wonder if you could help :

On one project I have a target that builds a shared library target in C 
++ exclusively. On another target I have a objC app that uses the  
first as a project dependency.


When I call a method on the library with a pointer to a STL map  
(std::map) as an argument, the linker  
complains it can't find it. I made a test method on the lib that takes  
only a std::string and it works. Passing a std::map fails  
with the same error. Other methods in the lib that don't use STL are  
found by the linker.


Don't know what is happening, or if there is any limitation because of  
STL.



On Sep 12, 2008, at 9:29 AM, [EMAIL PROTECTED] wrote:



On 12 Sep 2008, at 10:17, Daniel Luis dos Santos wrote:


Hello !

I have an objective C class and want to call a method on a class in  
C++. As argument to the C++ class is a map instance of the STL.

The ObjC class definition is on a file with a mm extension.

I have std::map *var as a member variable of the ObjC class. When I  
compile the code there is an error saying :


/Users/dlsa/code/Finema/trunk/LiquidSurfaces/src/ 
CVDisplayPipeline.h:20: error: using-declaration for non-member at  
class scope


How do I do this ?
___



Does this happen when you compile CVDisplayPipeline.mm, or when you  
compile another file which might only be a .m file? If it is the  
latter, then that would be your problem since you are no longer  
compiling Obj-C++.


If it is in CVDisplayPipeline.mm then It could just be that you  
aren't including the right header file in CVDisplayPipeline.h (  
I think).


If you do have to include your .h file in other .m files, you can  
workaround the problem of having pointers to C++ classes like so:


#if defined(__cplusplus)
#include 
typedef std::map* std_mapPtr;
#else
typedef void* std_mapPtr;
#endif

@interface MyClass: NSObject
{
std_mapPtr mMap;
}

-(std_mapPtr) map;

-(void) setMap: (std_mapPtr) aMap;
@end;

Matt


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSXMLParser bug?

2008-09-12 Thread Graham Cox


On 12 Sep 2008, at 7:30 am, Ken Ferry wrote:


On Thu, Sep 11, 2008 at 2:23 PM, Ken Ferry <[EMAIL PROTECTED]> wrote:

Hi Graham,

That's backwards.. only subclassers are concerned with designated
initializers.  Someone creating an object can call any init method.

Maybe it's easiest to describe by intent.
(1) Every class has at least one, and possibly more, designated  
initializers.

(2) When an object is created, exactly one of the designated
initializers at every level of the class hierarchy should execute.

You can figure out your responsibilities from the intent.  If you  
have

initialization that needs to be done,
(1) You must override every designated initializer of your  
superclass.
(2) The designated initializers of _your_ class are the ones that  
call

a super with an init method that is a designated initializer of the
superclass.  Your designated initializers needn't have any
relationship to the designated initializers of your superclass (i.e.,
neither a subset nor a superset).

If you add a new designated initializer to a class, you introduce a
new responsibility to all of your subclassers, so it's to be avoided
in frameworks.  It's easy to avoid by calling [self someInitMethod]
instead of [super someInitMethod] when you introduce a new init
method, or by calling super with some method that is not a designated
initializer of the superclass.

See also James Dempsey and the breakpoints, "Designated Initializer".
.


For some classes (NSView springs to mind) I can't see an
effective way that init could be overridden for all possible  
classes.


- (id)init {
  return [self initWithFrame:NSZeroRect];
}


Actually, maybe this example is exploring.  What does this do?  Well,
init is a designated initializer of NSView's superclass, NSResponder.
However, with this implementation, -init is not a designated
initializer of NSView.  If someone calls [[NSView alloc] init], you'll
see this sequence of calls:

[NSView init] - not designated
[NSView initWithFrame] - designated
[NSResponder init] - designated
[NSObject init] - designated

This is the usual pattern at init.  Let's say a user calls a
non-designated initializer.  That may call other non-designated
initializers, but at some point one of those will call self with
something that is a designated init method of the leaf class.  That
method will call [super aDesignatedInitializerOfTheNextClassUp] and so
on, all the way to the root.  Then the whole mess returns.

-Ken


So, what you're saying is that the OP was right - init *should* be  
overridden to call the designated initializer if init itself isn't it.  
In that case it would appear that NSXMLParser does indeed have a bug.  
It also suggests that the documentation which I linked needs to  
clarify this because it's not explicitly stated.



By the way, the operative word with my comment regarding NSView was  
"effective". I can see that init can just pass a zero rect, but does  
that make a useful view? No, not really - but perhaps I miss the point  
a bit there. The idea is to return an object that is viable, and won't  
crash, right? Not one that is actually useful (without further set up).









On 11 Sep 2008, at 10:50 pm, Karan, Cem (Civ, ARL/CISD) wrote:


I thought that all initializers had to call through the designated
initializer, which means that init should be overridden to call
initWithData:.  Am I wrong?



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Getting access to image attributes in IKImageBrowser

2008-09-12 Thread Laurent Cerveau

Hi

I am working with IKImageBrowser and would like to display the size of  
the image as subtitle in the browser. So I implemented an  
imageSubtitle method of the IKImageBrowserItem and started using  
ImageIO to get those info. However it looks to me that I am doing  
unnecessary work as the IKImagebrowser shouldalready know all this.


Is there a way to easily get access to this information from one of  
the IKImageBrowserItem support method?


thanks

laurent
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Link aganist

2008-09-12 Thread dexter morgan
I've made as you suggested but nothing is changed.
Take a look here:
http://img440.imageshack.us/img440/103/picture1it4.png
thanks a lot

On Fri, Sep 12, 2008 at 12:27 AM, Meik Schuetz <[EMAIL PROTECTED]> wrote:
> Hi there,
> in the target properties, make sure the header file search path is set to
> the directory in which you've got the 3rd party header files. To link the
> dylib files with the project, click on Project -> Add to project and select
> the necessary dylib files.
>
> Hope that helps.
> Meik
>
>
> On Sep 11, 2008, at 11:04 PM, dexter morgan wrote:
>
>> Hello List,
>> I've a simple c project that uses semaphores.
>> I've tried to include it inside the main.c
>>
>> #include 
>> #include 
>> #include 
>> #include 
>> #include 
>> #include 
>> #include 
>> #include 
>> #include 
>> #include 
>>
>> but xcode won't to compile it. Anyone can help 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/cocoa%40consjuri.net
>>
>> 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: Link aganist

2008-09-12 Thread Peter O'Gorman
dexter morgan wrote:
> I've made as you suggested but nothing is changed.
> Take a look here:
> http://img440.imageshack.us/img440/103/picture1it4.png
> thanks a lot
> 

typo, change semclt to semctl in main.

Peter
-- 
Peter O'Gorman
http://pogma.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: Mixing ObjC and C++ STL on same ObjC source file

2008-09-12 Thread Dave Carrigan


On Sep 12, 2008, at 1:17 AM, Daniel Luis dos Santos wrote:


I have std::map *var as a member variable of the ObjC class.


Is this really how it's declared? std::map is a template, so you have  
to do something like:


  std::map* var;

Or better yet:

  typedef std::map my_map_type;

   ...

  my_map_type* var;

/Users/dlsa/code/Finema/trunk/LiquidSurfaces/src/CVDisplayPipeline.h: 
20: error: using-declaration for non-member at class scope


I've verified that this is the error that I get if I don't specify a  
proper template. I also get the error if I neglect to #include ,  
so that may also be your problem.


--
Dave Carrigan
[EMAIL PROTECTED]
Seattle, WA, USA



PGP.sig
Description: This is a digitally signed message part
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 Migration Progress

2008-09-12 Thread Doug Penny
On Thu, Sep 11, 2008 at 8:02 PM, Adam Swift <[EMAIL PROTECTED]> wrote:

> No, you'll need to do a manual migration so you can register yourself as an
> observer of the NSMigrationManager's migrationProgress

Thanks Adam, I figured that was the case.  I didn't want to spend much
time on this feature so I decided to test the data store for
compatibility and if it needs to be migrated I pop up a window with an
indeterminate progress indicator that is displayed until
-addPersistentStoreWithType:configuration:URL:options:error: is
returned.

Doug
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSXMLParser bug?

2008-09-12 Thread Michael Ash
On Fri, Sep 12, 2008 at 6:55 AM, Graham Cox <[EMAIL PROTECTED]> wrote:
> By the way, the operative word with my comment regarding NSView was
> "effective". I can see that init can just pass a zero rect, but does that
> make a useful view? No, not really - but perhaps I miss the point a bit
> there. The idea is to return an object that is viable, and won't crash,
> right? Not one that is actually useful (without further set up).

Many objects aren't useful without further setup no matter how they're
initialized.

I personally use NSView with a plain -init sometimes. It's useful when
using autosizing controls. For example, I can alloc/init an
NSTextField, configure it, set its value, then call -sizeToFit to get
it to match its contents. Using -initWithFrame: would just be
redundant.

Really, a plain -init should give you one of three things:

1) An object that is ready for normal use. For example, NSFileManager.

2) An object which can be further configured for normal use. For
example, NSView.

3) An object which, while not necessarily useful, is still functional
as a blank/empty object. For example, NSArray.

Sometimes -init can't help but give you an object that's fairly
useless, but it shouldn't be crashing, in any case.

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: clearing NSView outside of drawRect:

2008-09-12 Thread Chinh Nguyen


On Sep 11, 2008, at 10:16 PM, Ken Ferry wrote:


If I read this correctly, you're hoping that you can erase some of the
drawing done in your overlay view, just revealing the original drawing
in your complex background view.




You can get the effect you want in layer backed mode (c.f. -[NSView
setWantsLayer:]).  Then each view has its own buffer, so your
selection drawing doesn't wipe out the background drawing, it only
covers it.  You don't need to do anything funky with drawing outside
of drawRect:, though.  Just call setNeedsDisplay: on the parts of your
selection view that need to be redrawn.  This will not cause the
background view to redraw.  It's similar to using an overlay window,
just easier.


Thanks for your suggestions.  Unfortunately, I can't use [NSView  
setWantsLayer:] because I'm trying to support Tiger.  I had assumed  
that views already had their own backing stores which is why I went  
down this route.  Your explanation help clear that up and point me in  
the right direction.


As for using setNeedsDisplay instead of drawing immediately during  
mouseDragged events.  My selection is several pixels behind my mouse  
as I'm dragging it when I use setNeedsDisplay: (when I tried  
setWantsLayer:, it was only a few pixels behind).  When I draw  
immediately, the selection stays right under the mouse as I drag it.   
It's not my background view's drawRect: because I turned it off to  
confirm whether it was the source of the lag and it's not my selection  
view's drawRect: because my test case is simply drawing a line between  
a fixed point and the current location of the mouse.  I have not tried  
a mouse-tracking loop yet.


-Chinh Nguyen
[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]


Question about dataWithPDFInsideRect:

2008-09-12 Thread Chris Goedde

Hi all,

Suppose I have a model (myModel) and its view (myModelView) which is a  
subclass of NSView. myModel has an update method that updates the  
model, and changes in the view are all drawn inside the drawRect:  
method of myModelView. If I have the following sequence:


[ myModel update ];
[ myModelView setNeedsDisplay: YES ];
myModelViewData = [ myModelView dataWithPDFInsideRect: [ myModelView  
bounds ] ];


Is the data I get back from dataWithPDFInsideRect: guaranteed to  
reflect the last changes that stem from [ myModel update ]? Or is it  
possible that I might get data that's essentially cached from a view  
of the model from some previous state? Hope that makes sense.


Thanks.

Chris Goedde

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


NSBezierPath lineToPoint: Rate

2008-09-12 Thread Ian was here
I have an app that uses a pen tool. If I move the mouse slowly, the free-hand 
drawing looks smooth, but as I increase the speed at which I move the mouse, 
the line gets bumpy. I am calling lineToPoint: in the mouseDragged: method of 
my view.

Has anyone found a solution to this problem.


  
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Question about dataWithPDFInsideRect:

2008-09-12 Thread Benjamin Stiglitz
Suppose I have a model (myModel) and its view (myModelView) which is  
a subclass of NSView. myModel has an update method that updates the  
model, and changes in the view are all drawn inside the drawRect:  
method of myModelView. If I have the following sequence:


[ myModel update ];
[ myModelView setNeedsDisplay: YES ];
myModelViewData = [ myModelView dataWithPDFInsideRect: [ myModelView  
bounds ] ];


Is the data I get back from dataWithPDFInsideRect: guaranteed to  
reflect the last changes that stem from [ myModel update ]? Or is it  
possible that I might get data that's essentially cached from a view  
of the model from some previous state? Hope that makes sense.


Yes; -[NSView dataWithPDFInsideRect:] will create a PDF graphics  
context and eventually end up calling -[NSView drawRect:] with the  
passed bounds.


-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]


Two Dimensional Array

2008-09-12 Thread Jordon Hirshon
I'm new to Objective-C.  Can someone suggest an approach to building a two 
dimensional array of integers?

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]


Using NSAlert with PyObjc - basics

2008-09-12 Thread Tobias Prinz

Hello there,
I am trying to display a little pop-up using NSAlert. I've used a  
fairly standard snippet from this page (which is written in German,  
plus it is ObjC code): http://cocoa-coding.de/nsalert/nsalert.html


My translation to Python is the following. Yes, that's step-by-step  
print-debugging, ugly, but it should run everywhere this way. Well  
since it does not run at all, it should get stuck everywhere (but well- 
documented):


Code:

import objc
from AppKit import *
from Foundation import *

class MessageTest(object):

def createAlert_(self, timer):
print "Step B1"
alert = NSAlert.alloc().init()
print "Step B2"
alert.setMessageText_("Important message")
print "Step B3"
alert.setInformativeText_("Please listen, this is a very  
important message!")

print "Step B4"
alert.setAlertStyle_(NSInformationalAlertStyle)
print "Step B5"
buttonPressed=alert.runModal();
print "Step B6: " + str(buttonPressed)


def startRunLoop(self):
print "Step A1"
 
NSTimer 
.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(1,  
self, 'createAlert:', "", False)

print "Step A2"
runLoop = NSRunLoop.currentRunLoop()
print "Step A3"
runLoop.run()
print "Step A4"

MessageTest().startRunLoop()



I am using Mac OS X 10.5.4.

What happens is that after executing this code (both via Eclipse and  
from the shell):


a) I get to see the rocket icon which symbolizes a Python process. The  
icon bounces a bit like pacman on crack, then stops moving after a  
while.


b) I see the output:
Step A1
Step A2
Step A3
Step B1
Step B2
Step B3
Step B4
Step B5
Step B6: 0

The process keeps running. If I cancel it, I get a lengthy error log.  
The pop-up is nowhere around. Is there something different I have to  
do to get Objective-C appkit stuff running in Python? Maybe I missed  
some basics, but until now I haven't found a tutorial geared towards  
Mac GUIs in Python/PyObjC. So if one of you can give me some  
directions, I'd appreciate that very much.


Kind regards,
Tierlieb

P.S.: I searched for NSAlert on the list an did not find a single e- 
mail. Weird... or am I using the wrong list? There is no AppKit group  
around, so I figure I am right asking here...

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


NSArrayController's canRemove controllerkey and toolbar items problem

2008-09-12 Thread Sacha
Hi,

I ran into a problem where the canRemove controllerkey doesn't correctly
disables a toolbar item.

What I first had, was a simple toolbar item, who's enabled property was
bound to the canRemove controllerkey of an arraycontroller in my nib, and
that sent an action to the same arraycontroller when clicked with the
message remove.
So far I got it working perfectly.

I extended it using a sheet to avoid accidental clicks. So I made a
controller class (more or less the same as in the documentation from ADC):

@interface DeleteRecordConfirmationSheet : NSObject {
IBOutlet NSWindow *targetWindow;
IBOutlet NSArrayController *entryArray;
}

- (IBAction)deleteSelectedBlogEntry:(id)sender;

@end

@implementation DeleteRecordConfirmationSheet

- (IBAction)deleteSelectedBlogEntry:(id)sender
{
NSBeginAlertSheet(@"Do you really want to delete the selected entry?",
  @"Remove",
  @"Cancel",
  nil,
  targetWindow,
  self,

@selector(sheetDidEndShouldDelete:returnCode:contextInfo:),
  nil,
  nil,
  @"There is no undo for this operation.");
}

- (void)sheetDidEndShouldDelete:(NSWindow *)sheet returnCode:(int)returnCode
contextInfo:(void *)contextInfo
{
if (returnCode == NSAlertDefaultReturn)
{
[entryArray removeObjects:[entryArray selectedObjects]];
}
}

@end


Pretty simple and straightforward.
ToolbarItem bound to canRemove controllerkey, and sentaction to the
controller class, outlets bound to my window and arraycontroller
respectively.
It works fine for deleting the the array objects, but the toolbaritem isn't
disabled anymore (while it did work correct not using the controller).
For instance, when I add an item, press remove, confirm, it "flickers"
disabled and immediately is enabled back again (while the array is empty).
If no arrayobject is selected (using a table view) even with when the list
is not empty, it is enabled.

For testing, I placed a simple pushbutton on my window contentview, bound it
to the controllerkey and arraycontroller and it just enables/disables
perfectly (asynchronously with the toolbaritem not working).

I can't help it finding this behaviour strange...
Nothing found on google about somebody having a similar problem either...

Greets.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSXMLParser bug?

2008-09-12 Thread Karan, Cem (Civ, ARL/CISD)

> > This is the usual pattern at init.  Let's say a user calls a 
> > non-designated initializer.  That may call other non-designated 
> > initializers, but at some point one of those will call self with 
> > something that is a designated init method of the leaf class.  That 
> > method will call [super 
> aDesignatedInitializerOfTheNextClassUp] and so 
> > on, all the way to the root.  Then the whole mess returns.
> >
> > -Ken
> 
> So, what you're saying is that the OP was right - init 
> *should* be overridden to call the designated initializer if 
> init itself isn't it.  
> In that case it would appear that NSXMLParser does indeed 
> have a bug.  
> It also suggests that the documentation which I linked needs 
> to clarify this because it's not explicitly stated.
> 
> 
> By the way, the operative word with my comment regarding 
> NSView was "effective". I can see that init can just pass a 
> zero rect, but does that make a useful view? No, not really - 
> but perhaps I miss the point a bit there. The idea is to 
> return an object that is viable, and won't crash, right? Not 
> one that is actually useful (without further set up).

That is actually how I read it; that even if the object can't do
anything useful (e.g. [[NSNumber alloc] init]), it shouldn't crash when
it receives a release message.  For objects that require some kind of
initialization to work right, I keep a boolean around that signals if
the instance was properly initialized.  My class's designated
initializer knows how to set that properly, but the superclasses don't,
and if you call a method without correctly initializing the instance, an
exception is raised telling you why you can't do that.  This isn't
ideal, but it works fairly well in practice.

Thanks,
Cem Karan
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Two Dimensional Array

2008-09-12 Thread Shawn Erickson
On Fri, Sep 12, 2008 at 5:05 AM, Jordon Hirshon <[EMAIL PROTECTED]> wrote:

> I'm new to Objective-C.  Can someone suggest an approach to building a two 
> dimensional array of integers?

Objective-C is a super set of C and you question appears to be more of
a C question. In other words you would do it the way you would in C.

int array[5][5];

-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: Two Dimensional Array

2008-09-12 Thread Jamie Hardt

2 ways-

* Identically to C:

int myArray[X_SIZE][Y_SIZE];

This will perform much faster but will have all of the drawbacks of a  
dumb C array.


* Or with NSArray/NSMutableArray:

NSMutableArray *myArray = [NSMutableArray arrayWithObjects: 
[NSMutableArray array],[NSMutableArray array],nil];

etc...

This will perform more slowly but will be much less painful to work  
with.


What specifically are you trying to do?

On Sep 12, 2008, at 5:05 AM, Jordon Hirshon wrote:

I'm new to Objective-C.  Can someone suggest an approach to building  
a two dimensional array of integers?


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Leopard exception handling driving me crazy!

2008-09-12 Thread Gerd Knops

OK, so:

[[NSExceptionHandler defaultExceptionHandler]setDelegate:self];
[[NSExceptionHandler defaultExceptionHandler]setExceptionHandlingMask:
0
| NSHandleUncaughtExceptionMask
| NSHandleUncaughtSystemExceptionMask
| NSHandleUncaughtRuntimeErrorMask
// | NSHandleTopLevelExceptionMask
];

If I include "NSHandleTopLevelExceptionMask", my nested exception  
handlers do NOT get called and it jumps right to the delegates '- 
exceptionHandler:shouldHandleException:mask:' method (mask being 128,  
NSHandleTopLevelExceptionMask). It catches the exception deep down in  
the code, even though there are 2 levels of handlers around it.


If I don't include NSHandleTopLevelExceptionMask, the nested handlers  
get executed (they are throwing other exceptions containing more  
information and referencing the original exception), but the exception  
finally reaching the delegate is not the exception thrown at my top- 
level handler (and it definitely is being thrown), but rather this  
less than useful:


Uncaught system exception: signal 5

with no apparent access to that last exception my code actually  
generated. The mask reported is 8, NSHandleUncaughtSystemExceptionMask.



Now what I was expecting is that with NSHandleTopLevelExceptionMask  
included, the handler would only receive exceptions escaping my top  
level exception handler, rather than the 'original' exception deep  
down in the code.


Where am I going wrong?

Thanks

Gerd


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Animate a CGPath

2008-09-12 Thread David Duncan

On Sep 11, 2008, at 12:21 PM, Daniel Weber wrote:

Hi everyone. I have an NSView with some appkit drawing code that I'm  
trying
to convert to core graphics drawing code. One thing I'm having  
trouble with
is the transition from NSBezierPath to CGPath. Basically in my  
application,
I want to animate the drawing a curve. In other words, I want to  
show the
path being drawn over a relatively long period of time (about 2  
seconds).
When I was using NSBezierPath, I would do this by first flattening  
the path,
then using a timer to call the draw method to draw elements 0 to 1,  
then 0

to 2, then 0 to 3, and so on until I reached the end of the curve. The
effect was that the user could see the curve being "animated". Is  
there a
way to "flatten" a CGPath? Is there another way to do this in Core  
Graphics?


It sounds like what you want is CGPathApply(). It will allow you to  
break a path down into its components and do whatever you please.


That said, it is probably cleaner to simply draw the individual  
components yourself rather than using a CGPathRef, as all of the path  
operations have equivalent functionality that can be done directly on  
the context.

--
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]


Programmatically dismiss NSPopUpButton menu

2008-09-12 Thread Jeff Johnson
I have a NSView that only appears in a window when a certain activity  
is in progress, and there's an NSPopUpButton in the view that acts as  
a gear menu with actions that relate to the activity in progress. The  
issue is that if the button's menu is still open when activity  
finishes and the view is removed from the window, the button is gone  
but the menu is still displayed, and I can't get the menu to dismiss  
before I remove the view.


The method -[NSPopUpButtonCell dismissPopUp] doesn't seem to work.  
I've filed  on that.


I've tried a bunch of different things to dismiss the popup menu, but  
none of them have worked. I'd greatly appreciate hearing about any  
proven techniques for dismissing the popup menu. Thanks!


-Jeff

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Newb: Targeting an instance of a class instantiated by a NIB file

2008-09-12 Thread Brad Gibbs
I'm working on an application with a single main window and a number  
of views and view controllers.  I have a navigation window that pops  
up and allows users to set preferences and also switch views in the  
main portion of the app's main window.


I want to write the code to switch views in the  
MainWindowController.m, since it controls the window that contains the  
views that will be switched.  But, the buttons that control the view  
switching are located on a panel being controlled by a different view  
controller.


The main window and its window controller are instantiated when the  
program is launched.  Creating another instance in the view controller  
that contains the buttons (either by adding a MainWindowController  
object in IB or by creating another instance in the view controller  
code) doesn't target the existing main window, and, therefore, doesn't  
cause views to be switched in the main window that is instantiated on  
launch.  So, how can I target the instance of the main window  
controller that was instantiated on launch from the NSViewController  
controlling the view with the view switching buttons, in order to  
switch views?  Or should I be doing something else entirely?



Thanks.

Brad
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Two Dimensional Array

2008-09-12 Thread Graff

On Sep 12, 2008, at 5:05 AM, Jordon Hirshon wrote:

I'm new to Objective-C.  Can someone suggest an approach to building  
a two dimensional array of integers?


You can either make an NSArray that contains other NSArrays or just  
use a c-style multidimensional array.


example of using an NSArray:

int myValue = 10;

// create the 2-D array
NSArray *twoD = [NSArray arrayWithObjects:
 [NSMutableArray new],
 [NSMutableArray new],
 [NSMutableArray new],
 [NSMutableArray new], nil];

// store the value as an NSNumber
[[twoD objectAtIndex:2] addObject:[NSNumber numberWithInt:myValue]];

// retrieve the value
	int retrievedValue = [[[twoD objectAtIndex:2] objectAtIndex:0]  
intValue];


example of using a c-array:

int myValue = 10;

// create the 2-D array
int twoD[4][6];

// store the value as an NSNumber
twoD[2][0] = myValue;

// retrieve the value
int retrievedValue = twoD[2][0];

There are advantages and disadvantages to each method.  If you poke  
around the internet you can find some pre-made objective-c classes  
that handle multi-dimensional arrays for you but for a simple 2-D  
array it's probably best to stick with something similar to what I've  
outlined here.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Transparent Background for a Progress Indicator (NSView)

2008-09-12 Thread Simon

Hi guys,

This is a quick question I hope! What's the most efficient way to make  
the progress indicator background transparent (I've got a screen shot  
of a quick test app[1])? Is there away to do this without redrawing  
the gradient in the background? I'm assuming that I could try and find  
out the dirty area if I need to...


Sorry in advance if I'm missing something, but your help will be  
greatly appreciated.


Thank-you
Simon

[1] http://stickupkid.com/cocoa/mailing-list/progress-gear.png
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Two Dimensional Array

2008-09-12 Thread Graff

On Sep 12, 2008, at 3:24 PM, Graff wrote:


// create the 2-D array
NSArray *twoD = [NSArray arrayWithObjects:
 [NSMutableArray new],
 [NSMutableArray new],
 [NSMutableArray new],
 [NSMutableArray new], nil];


I wrote this quickly without thinking about it.  The +new method is  
not the correct one to use in this example because it will create an  
object with a retain count of 1, which means that it will leak when  
the NSArray object is released since the NSArray automatically retains  
objects added to it.  It's better to use the +array method as follows:


// create the 2-D array
NSArray *twoD = [NSArray arrayWithObjects:
 [NSMutableArray array],
 [NSMutableArray array],
 [NSMutableArray array],
 [NSMutableArray array], nil];

This way the NSArray gets NSMutableArray objects with a retain count  
of 0 so they will be deallocated when the NSArray is deallocated and  
calls release on the objects it contains.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Newb: Targeting an instance of a class instantiated by a NIB file

2008-09-12 Thread Jamie Hardt

On Sep 12, 2008, at 12:17 PM, Brad Gibbs wrote:

I want to write the code to switch views in the  
MainWindowController.m, since it controls the window that contains  
the views that will be switched.  But, the buttons that control the  
view switching are located on a panel being controlled by a  
different view controller.



So you have the buttons on the navigation panel, that control the main  
window view.  You have a few options:


1) Connect the buttons on the panel to the changeView: (or whatever  
you call it) actions on the main window windowController.  This is the  
easiest.  Just leave your Navigation Panel in your main windows nib,  
and don't bother writing a window controller for it.  If the  
navigation panel starts getting more complicated and chatty with a  
bunch of other components, or particularly if it can alter document  
state, THEN consider making a separate NIB for it.


2) Implement changeView: on your Document class instead, and make the  
buttons on the panel send a changeView: selector to the first  
responder.  The changeView: message will eventually find its way to  
your NSDocument, and then you write code in the NSDocument that tells  
the MainWindowController to do the view switching.  All roads in the  
responder chain lead to the NSDocument eventually.


Jamie Hardt
The Sound Department
http://www.soundepartment.com/
http://www.imdb.com/name/nm0362504/

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Programmatically dismiss NSPopUpButton menu

2008-09-12 Thread Peter Ammon


On Sep 12, 2008, at 11:40 AM, Jeff Johnson wrote:

I have a NSView that only appears in a window when a certain  
activity is in progress, and there's an NSPopUpButton in the view  
that acts as a gear menu with actions that relate to the activity in  
progress. The issue is that if the button's menu is still open when  
activity finishes and the view is removed from the window, the  
button is gone but the menu is still displayed, and I can't get the  
menu to dismiss before I remove the view.


The method -[NSPopUpButtonCell dismissPopUp] doesn't seem to work.  
I've filed  on that.


I've tried a bunch of different things to dismiss the popup menu,  
but none of them have worked. I'd greatly appreciate hearing about  
any proven techniques for dismissing the popup menu. Thanks!


-Jeff



You're looking for -[NSMenu cancelTracking].

Note that this is somewhat against Mac OS X UI conventions, as menus  
normally don't go away unless the user dismisses them.  Imagine the  
user is about to click on a menu item, and the menu vanishes and the  
user triggers whatever was behind it.  Consider instead handling the  
case where the user chooses a menu item after the operation has  
finished with a gentle error message.


-Peter

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newb: Targeting an instance of a class instantiated by a NIB file

2008-09-12 Thread Brad Gibbs
Thanks for the reply.  Unfortunately, the navigation panel is too  
complicated not to have a controller (it has several, actually).  I  
haven't used the responder chain yet, but I'll give it a go.  It's  
disappointing that there's no way to target the instance directly...



On Sep 12, 2008, at 12:41 PM, Jamie Hardt wrote:


On Sep 12, 2008, at 12:17 PM, Brad Gibbs wrote:

I want to write the code to switch views in the  
MainWindowController.m, since it controls the window that contains  
the views that will be switched.  But, the buttons that control the  
view switching are located on a panel being controlled by a  
different view controller.



So you have the buttons on the navigation panel, that control the  
main window view.  You have a few options:


1) Connect the buttons on the panel to the changeView: (or whatever  
you call it) actions on the main window windowController.  This is  
the easiest.  Just leave your Navigation Panel in your main windows  
nib, and don't bother writing a window controller for it.  If the  
navigation panel starts getting more complicated and chatty with a  
bunch of other components, or particularly if it can alter document  
state, THEN consider making a separate NIB for it.


2) Implement changeView: on your Document class instead, and make  
the buttons on the panel send a changeView: selector to the first  
responder.  The changeView: message will eventually find its way to  
your NSDocument, and then you write code in the NSDocument that  
tells the MainWindowController to do the view switching.  All roads  
in the responder chain lead to the NSDocument eventually.


Jamie Hardt
The Sound Department
http://www.soundepartment.com/
http://www.imdb.com/name/nm0362504/



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Can anyone explain this?

2008-09-12 Thread Roland Silver

Can anyone explain this?
The value of the expression is apparently different from the value of  
a variable assigned to that expression:


	double pitch = A0Pitch * pow(2.0, ntones/ 
currentTonesPerOctave(voice)) ;
	NSLog(@"expression value: %f", A0Pitch * pow(2.0, ntones/ 
currentTonesPerOctave(voice)));

2008-09-12 16:25:08.095 AttoComp[10566:813] pitch value: 28.305812
NSLog(@"variable value: %f", pitch);
2008-09-12 16:25:08.094 AttoComp[10566:813] pitch variable: nan

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Newb: Targeting an instance of a class instantiated by a NIB file

2008-09-12 Thread Jonathan Hess

Hey Brad -

So it sounds like you have two controllers, A, and B, and they each  
have their own NIB. Sound like you're on the right track. Now you want  
to have an action in B's NIB affect controller A. Does controller B  
have an instance variable, or other mechanism, for referencing  
controller A? If so, you could put an action method on controller B  
and have that be the target of your button in NIB B. The  
implementation of that action can then call a method on controller A.


Jon Hess


On Sep 12, 2008, at 12:17 PM, Brad Gibbs wrote:

I'm working on an application with a single main window and a number  
of views and view controllers.  I have a navigation window that pops  
up and allows users to set preferences and also switch views in the  
main portion of the app's main window.


I want to write the code to switch views in the  
MainWindowController.m, since it controls the window that contains  
the views that will be switched.  But, the buttons that control the  
view switching are located on a panel being controlled by a  
different view controller.


The main window and its window controller are instantiated when the  
program is launched.  Creating another instance in the view  
controller that contains the buttons (either by adding a  
MainWindowController object in IB or by creating another instance in  
the view controller code) doesn't target the existing main window,  
and, therefore, doesn't cause views to be switched in the main  
window that is instantiated on launch.  So, how can I target the  
instance of the main window controller that was instantiated on  
launch from the NSViewController controlling the view with the view  
switching buttons, in order to switch views?  Or should I be doing  
something else entirely?



Thanks.

Brad
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jhess%40apple.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: Programmatically dismiss NSPopUpButton menu

2008-09-12 Thread Jeff Johnson

On Sep 12, 2008, at 3:16 PM, Peter Ammon wrote:


On Sep 12, 2008, at 11:40 AM, Jeff Johnson wrote:

I have a NSView that only appears in a window when a certain  
activity is in progress, and there's an NSPopUpButton in the view  
that acts as a gear menu with actions that relate to the activity  
in progress. The issue is that if the button's menu is still open  
when activity finishes and the view is removed from the window,  
the button is gone but the menu is still displayed, and I can't  
get the menu to dismiss before I remove the view.


The method -[NSPopUpButtonCell dismissPopUp] doesn't seem to work.  
I've filed  on that.


I've tried a bunch of different things to dismiss the popup menu,  
but none of them have worked. I'd greatly appreciate hearing about  
any proven techniques for dismissing the popup menu. Thanks!


-Jeff



You're looking for -[NSMenu cancelTracking].


Ah yes, thanks! That's 10.5-only? I didn't see it because the app  
still supports Tiger, so I was looking in the 10.4 docs. Is there a  
10.4 method for this?


Note that this is somewhat against Mac OS X UI conventions, as  
menus normally don't go away unless the user dismisses them.


Yes, the UI itself is a little unconventional, because the popup  
button itself, along with the containing view, disappears, so I  
didn't want to leave a orphaned menu.


Imagine the user is about to click on a menu item, and the menu  
vanishes and the user triggers whatever was behind it.  Consider  
instead handling the case where the user chooses a menu item after  
the operation has finished with a gentle error message.



Good point about accidentally triggering what's behind the menu. I  
don't know if I want to bother the user with an error message, since  
it's a matter of timing. I could disable all the menu items, though,  
right?


-Jeff

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Newb: Targeting an instance of a class instantiated by a NIB file

2008-09-12 Thread Jamie Hardt

On Sep 12, 2008, at 1:30 PM, Brad Gibbs wrote:

It's disappointing that there's no way to target the instance  
directly...



By design, an object freezedried in a nib cannot be connected to  
objects in other nibs, mainly because this would cause loading one nib  
to load others.  If you have to load 1+n nibs in order to resolve all  
the outlets in one nib, that sortof defeats the purpose of nibs in the  
first place, which is to allow objects to be decoded piecemeal on  
demand.


The responder chain is your friend here.  Instead of having to bind  
every last button and widget to a particular object, you just tell it  
what message to send to the first responder, and when the program runs  
the widgets automatically act on the thing the user is looking at.   
For example, the -close: action that the "Close" Menu bar item sends  
isn't bound to any windows, it just yells "-close:" at the first  
responder.  If the user is in a text field, the text field hears "- 
close:" and recognizes it as a message it cannot respond to, so it  
hands it to the next responder, it's enclosing superview.  This goes  
on until "-close:" hits the NSWindow, the final enclosing superview  
there is, and it DOES know how to handle it, and it takes the  
appropriate action.  "-save:" works the same way, except NSWindows  
don't respond to "-save:", documents do, so in this case the message  
is referred all the way back to the NSDocument subclass.  "-quit:"  
gets referred all the way back to your NSApplication, etc.


This is an EXTREMELY powerful part of Cocoa.  Your menubar can have a  
"-checkSpelling:" action and whatever object is in the user's focus at  
that moment can check it's spelling, all you have to do is make sure  
that responders that can be spell-checked have a "checkSpelling:"  
action.  The NSColorPanel works by simply sending a "changeColor:"  
message down the responder chain, and text views, color wells, and  
other classes all respond to this in appropriate ways.  The  
NSFontPanel works in a very similar manner.


On Sep 12, 2008, at 1:38 PM, Jonathan Hess wrote:

So it sounds like you have two controllers, A, and B, and they each  
have their own NIB. Sound like you're on the right track. Now you  
want to have an action in B's NIB affect controller A. Does  
controller B have an instance variable, or other mechanism, for  
referencing controller A? If so, you could put an action method on  
controller B and have that be the target of your button in NIB B.  
The implementation of that action can then call a method on  
controller A.


This can work just as well.  In your document class, after you've made  
the window controllers with -makeWindowControllers, hand them both a  
weak ref to the other, and then use methods on one to pass thru  
actions to the other.



Jamie Hardt
The Sound Department
http://www.soundepartment.com/
http://www.imdb.com/name/nm0362504/

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


App name from Bundle Identifier?

2008-09-12 Thread Dave DeLong

Hi everyone,

I've been looking inside NSWorkspace, NSBundle, NSApplication,  
NSFileWrapper, etc for some way to get the display name of an  
application from it's bundle identifier, but I can't find anything.   
Is there a way to do this?  For example, if I have  
"com.apple.InterfaceBuilder3", I'd like to get back "Interface Builder".


Thanks,

Dave DeLong
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: App name from Bundle Identifier?

2008-09-12 Thread Jamie Hardt

Dave-

Just a thought

NSString *path = [[NSWorkspace sharedWorkspace]  
absolutePathForAppBundleWithIdentifier:bundleIdentifier];


NSString *appName = [[path lastPathComponent]  
stringByDeletingPathExtension];


On Sep 12, 2008, at 2:06 PM, Dave DeLong wrote:


Hi everyone,

I've been looking inside NSWorkspace, NSBundle, NSApplication,  
NSFileWrapper, etc for some way to get the display name of an  
application from it's bundle identifier, but I can't find anything.   
Is there a way to do this?  For example, if I have  
"com.apple.InterfaceBuilder3", I'd like to get back "Interface  
Builder".

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: App name from Bundle Identifier?

2008-09-12 Thread Dave DeLong
Thanks for the idea.  I'm sure it will work under most situations, but  
there are times when what's displayed in the Finder (ie it's absolute  
path) is not necessarily the same thing as the actual application name.


For example, I have BBEdit 8 and BBEdit 9 (trial) right now.  BBEdit 8  
is at "/Applications/BBEdit.app", and BBEdit 9 is at "/Applications/ 
BBEdit 9.app", yet they both have the same "NSApplicationName"/ 
CFBundleName of "BBEdit".


I'd like to have a method that will always work, no matter what the  
path is.  If that's not possible, then what you outlined is the next  
best thing.


Thanks!

Dave

On Sep 12, 2008, at 3:16 PM, Jamie Hardt wrote:


Dave-

Just a thought

NSString *path = [[NSWorkspace sharedWorkspace]  
absolutePathForAppBundleWithIdentifier:bundleIdentifier];


NSString *appName = [[path lastPathComponent]  
stringByDeletingPathExtension];


On Sep 12, 2008, at 2:06 PM, Dave DeLong wrote:


Hi everyone,

I've been looking inside NSWorkspace, NSBundle, NSApplication,  
NSFileWrapper, etc for some way to get the display name of an  
application from it's bundle identifier, but I can't find  
anything.  Is there a way to do this?  For example, if I have  
"com.apple.InterfaceBuilder3", I'd like to get back "Interface  
Builder".


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Windows

2008-09-12 Thread John MacMullin
Does the standard Windows menu manage and show all application  
windows?  If so, under what conditions do windows not get listed in  
the pull down?


On the other hand, it is up to the programmer to manage the list and  
enable and disable windows as they become key and front?


Thanks,

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]


Re: Newb: Targeting an instance of a class instantiated by a NIB file

2008-09-12 Thread Brad Gibbs

If I'm reading your mail correctly, I've tried that without success.

I have a MainWindowController controlling MainWindow.  On  
MainWindow.xib is a button which launches another window  
(MainMenu,xib) with a window controller (MainMenuWindowController.m).   
A couple of NSViewControllers down is a view with the buttons in  
question.


I've tried creating an instance of MainWindowController in that view's  
NSViewController (declaring MainWindowController  
*iMainWindowController in the interface, using @property and  
@synthesize and then calling iMainWindowController =  
[[MainWindowController alloc] init] in the NSViewController's  
implementation section).


I can tell the method is being called by an NSLog statement posted to  
the Console, but the view doesn't swap in.  I'm assuming this is  
because I've programmatically created another instance of the  
MainWindowController class in the NSViewController and I'm targeting  
that instance with the buttons, rather than the instance created at  
launch, which is controlling the MainWindow.  Calling a method on the  
MainWindowController instance created by the NSViewController would  
still cause the log file to print the message without swapping in the  
view on the instance of the Main Window created when I launch the  
app.  So, I'm left to assume that I need to target the instance  
created at launch.


According to the Event Handling Guide:
 If an NSWindowController object is managing the window, it becomes  
the final next responder.


Is this going to be a problem, since the NSViewController with the  
button code is underneath its own NSWindowController?  Would the  
responder chain just stop there and so that messages wouldn't make  
their way over and up to the MainWindowController?


Thanks again.

Brad


On Sep 12, 2008, at 1:38 PM, Jonathan Hess wrote:


Hey Brad -

So it sounds like you have two controllers, A, and B, and they each  
have their own NIB. Sound like you're on the right track. Now you  
want to have an action in B's NIB affect controller A. Does  
controller B have an instance variable, or other mechanism, for  
referencing controller A? If so, you could put an action method on  
controller B and have that be the target of your button in NIB B.  
The implementation of that action can then call a method on  
controller A.


Jon Hess


On Sep 12, 2008, at 12:17 PM, Brad Gibbs wrote:

I'm working on an application with a single main window and a  
number of views and view controllers.  I have a navigation window  
that pops up and allows users to set preferences and also switch  
views in the main portion of the app's main window.


I want to write the code to switch views in the  
MainWindowController.m, since it controls the window that contains  
the views that will be switched.  But, the buttons that control the  
view switching are located on a panel being controlled by a  
different view controller.


The main window and its window controller are instantiated when the  
program is launched.  Creating another instance in the view  
controller that contains the buttons (either by adding a  
MainWindowController object in IB or by creating another instance  
in the view controller code) doesn't target the existing main  
window, and, therefore, doesn't cause views to be switched in the  
main window that is instantiated on launch.  So, how can I target  
the instance of the main window controller that was instantiated on  
launch from the NSViewController controlling the view with the view  
switching buttons, in order to switch views?  Or should I be doing  
something else entirely?



Thanks.

Brad
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jhess%40apple.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: Transparent Background for a Progress Indicator (NSView)

2008-09-12 Thread Corbin Dunn


On Sep 12, 2008, at 12:25 PM, Simon wrote:


Hi guys,

This is a quick question I hope! What's the most efficient way to  
make the progress indicator background transparent (I've got a  
screen shot of a quick test app[1])? Is there away to do this  
without redrawing the gradient in the background? I'm assuming that  
I could try and find out the dirty area if I need to...



No -- your superview should respect the dirtyRec.t

corbin




Sorry in advance if I'm missing something, but your help will be  
greatly appreciated.


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: App name from Bundle Identifier?

2008-09-12 Thread Ken Thomases
If you want the name displayed by the Finder, you want - 
[NSFileManager displayNameAtPath:].


If you want the name the app claims for itself, you want -[NSBundle  
objectForInfoDictionaryKey:] called on the bundle obtained from the  
path, passing (id)kCFBundleNameKey as the key.


Cheers,
Ken

On Sep 12, 2008, at 4:21 PM, Dave DeLong wrote:

Thanks for the idea.  I'm sure it will work under most situations,  
but there are times when what's displayed in the Finder (ie it's  
absolute path) is not necessarily the same thing as the actual  
application name.


For example, I have BBEdit 8 and BBEdit 9 (trial) right now.   
BBEdit 8 is at "/Applications/BBEdit.app", and BBEdit 9 is at "/ 
Applications/BBEdit 9.app", yet they both have the same  
"NSApplicationName"/CFBundleName of "BBEdit".


I'd like to have a method that will always work, no matter what the  
path is.  If that's not possible, then what you outlined is the  
next best thing.


Thanks!

Dave

On Sep 12, 2008, at 3:16 PM, Jamie Hardt wrote:


Dave-

Just a thought

NSString *path = [[NSWorkspace sharedWorkspace]  
absolutePathForAppBundleWithIdentifier:bundleIdentifier];


NSString *appName = [[path lastPathComponent]  
stringByDeletingPathExtension];


On Sep 12, 2008, at 2:06 PM, Dave DeLong wrote:


Hi everyone,

I've been looking inside NSWorkspace, NSBundle, NSApplication,  
NSFileWrapper, etc for some way to get the display name of an  
application from it's bundle identifier, but I can't find  
anything.  Is there a way to do this?  For example, if I have  
"com.apple.InterfaceBuilder3", I'd like to get back "Interface  
Builder".


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/ken%40codeweavers.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: App name from Bundle Identifier?

2008-09-12 Thread Jonathan Hess

Hey Dave -

You could start with -[NSWorkspace  
absolutePathForAppBundleWithIdentifier:] to get a path. Use that path  
to create an NSBundle instance with +[NSBundle bundleWithPath:], and  
then use the NSBundle to find the name. -[NSBundle  
objectForInfoDictionaryKey:] and -[NSBundle localizedInfoDictionary]  
can be used with CFBundleName and CFBundleDisplayName depending on  
whether or not the application in question has a localized name.  
Interface Builder does not have a localized name.


Also, this note (http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html#/ 
/apple_ref/doc/uid/20001431-110725) seems pertinent:


Before displaying a localized name for your bundle, the Finder  
compares the value of this key against the actual name of your bundle  
in the file system. If the two names match, the Finder proceeds to  
display the localized name from the appropriate InfoPlist.strings file  
of your bundle. If the names do not match, the Finder displays the  
file-system name.


Good Luck -
Jon Hess

On Sep 12, 2008, at 2:06 PM, Dave DeLong wrote:


Hi everyone,

I've been looking inside NSWorkspace, NSBundle, NSApplication,  
NSFileWrapper, etc for some way to get the display name of an  
application from it's bundle identifier, but I can't find anything.   
Is there a way to do this?  For example, if I have  
"com.apple.InterfaceBuilder3", I'd like to get back "Interface  
Builder".


Thanks,

Dave DeLong
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jhess%40apple.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: Newb: Targeting an instance of a class instantiated by a NIB file

2008-09-12 Thread Jonathan Hess


On Sep 12, 2008, at 2:25 PM, Brad Gibbs wrote:


If I'm reading your mail correctly, I've tried that without success.

I have a MainWindowController controlling MainWindow.  On  
MainWindow.xib is a button which launches another window  
(MainMenu,xib) with a window controller  
(MainMenuWindowController.m).  A couple of NSViewControllers down is  
a view with the buttons in question.


I've tried creating an instance of MainWindowController in that  
view's NSViewController (declaring MainWindowController  
*iMainWindowController in the interface, using @property and  
@synthesize and then calling iMainWindowController =  
[[MainWindowController alloc] init] in the NSViewController's  
implementation section).


The problem is that this creates a new 'MainWindowController'. The  
object you get in response to [[MainWindowController alloc] init] is  
unrelated to the one previously created.




I can tell the method is being called by an NSLog statement posted  
to the Console, but the view doesn't swap in.  I'm assuming this is  
because I've programmatically created another instance of the  
MainWindowController class in the NSViewController and I'm targeting  
that instance with the buttons, rather than the instance created at  
launch, which is controlling the MainWindow.


Exactly.

Calling a method on the MainWindowController instance created by the  
NSViewController would still cause the log file to print the message  
without swapping in the view on the instance of the Main Window  
created when I launch the app.  So, I'm left to assume that I need  
to target the instance created at launch.


Yep.



According to the Event Handling Guide:
 If an NSWindowController object is managing the window, it becomes  
the final next responder.


Is this going to be a problem, since the NSViewController with the  
button code is underneath its own NSWindowController?  Would the  
responder chain just stop there and so that messages wouldn't make  
their way over and up to the MainWindowController?


The method I suggested is independent of the responder chain. So this  
won't come into play. If you follow the other suggestion, this will be  
relevant.


If you choose to peruse my suggestion further, you'll need to make a  
way to find the original MainWindowController from the code inside of  
your view controller. If your document is holding onto a reference to  
the main window controller, perhaps your view controller can do  
something like 'self window] windowController] document]  
mainWindowController]'.


Good Luck -
Jon Hess



Thanks again.

Brad


On Sep 12, 2008, at 1:38 PM, Jonathan Hess wrote:


Hey Brad -

So it sounds like you have two controllers, A, and B, and they each  
have their own NIB. Sound like you're on the right track. Now you  
want to have an action in B's NIB affect controller A. Does  
controller B have an instance variable, or other mechanism, for  
referencing controller A? If so, you could put an action method on  
controller B and have that be the target of your button in NIB B.  
The implementation of that action can then call a method on  
controller A.


Jon Hess


On Sep 12, 2008, at 12:17 PM, Brad Gibbs wrote:

I'm working on an application with a single main window and a  
number of views and view controllers.  I have a navigation window  
that pops up and allows users to set preferences and also switch  
views in the main portion of the app's main window.


I want to write the code to switch views in the  
MainWindowController.m, since it controls the window that contains  
the views that will be switched.  But, the buttons that control  
the view switching are located on a panel being controlled by a  
different view controller.


The main window and its window controller are instantiated when  
the program is launched.  Creating another instance in the view  
controller that contains the buttons (either by adding a  
MainWindowController object in IB or by creating another instance  
in the view controller code) doesn't target the existing main  
window, and, therefore, doesn't cause views to be switched in the  
main window that is instantiated on launch.  So, how can I target  
the instance of the main window controller that was instantiated  
on launch from the NSViewController controlling the view with the  
view switching buttons, in order to switch views?  Or should I be  
doing something else entirely?



Thanks.

Brad
___

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

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

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

when should my NSWindowController be released?

2008-09-12 Thread Paul Archibald

Hey folks,

The app I am working on has 2 windows. My project has been to  
implement the 2nd window. I added a new nib file and a new class,  
MyController:NSWindowController. In the MainController:NSObject  
implementation, there is a MyController object, which can be shown or  
hidden by the user.


My question is about creating and destroying my controller. I have - 
initMyController and -windowDidLoad methods, which handle setting up  
my controller, but for some reason my -dealloc method is never  
called, even when the main app quits. In fact, the -dealloc method in  
the main controller is never called either. (I did not work on the  
main controller code.)


So, what is the general outline of properly allocating, initializing  
and deallocating an application and its elements? Can someone point  
me to the right documentation? I can't seem to find reference to this  
subject.


I thought -dealloc was called automagically on objects that are  
properly handled (ie: not leaking). I have been assuming the main app  
was behaving correctly, as I have not seen any warnings while  
debugging or even running some tools on it.


Paul
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


NSXMLParser and character entities?

2008-09-12 Thread Kai
When NSXMLParser hits a character entity like ä (-> German umlaut  
'ä'), it sends parser:resolveExternalEntityName:systemID: to its  
delegate and if this is not implemented or returns nil,  
parser:parseErrorOccurred: is called with  
NSXMLParserUndeclaredEntityError.


Am I supposed to resolve all these character entities myself? And if  
so, what should the NSData object returned by  
parser:resolveExternalEntityName:systemID: contain? Unicode? Which  
Unicode encoding?


But this can’t be, can it? I must be missing something simple.

Thanks for any hints
Kai



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSTableView works in 10.5 but not in 10.4

2008-09-12 Thread Ellen Chou
Hi all,

I have the similar problem in 10.4.x with another modaled dialog window that
only contains NSOutlineView table with 3 columns data. I'm pretty sure
reloadData is called.  This modaled dialog shows the contents correctly in
10.5.2.  Is there a call to refresh the display for the modaled dialog
window?

Any idea?

Thanks,
Ellen

On Tue, Sep 9, 2008 at 1:53 PM, Ellen Chou <[EMAIL PROTECTED]> wrote:

>  Thanks,
>
> reloadData resolve the problem with 10.4.8.
>
> - Ellen
>
>   On Mon, Sep 8, 2008 at 3:20 PM, Corbin Dunn <[EMAIL PROTECTED]> wrote:
>
>>
>> On Sep 8, 2008, at 2:36 PM, Ellen Chou wrote:
>>
>> Hi Stephane,
>>>
>>> Indeed, reloadData is not called at all.  But why can it work fine in
>>> 10.5.2?
>>>
>>> When and where I should call reloadData?
>>>
>>>
>> That's easy; after you change your model. When do you initialize your
>> arrays, etc? After that point, call reloadData. Possibly in -awakeFromNib.
>>
>> If it is working by chance on Leopard, then it is probably because of some
>> ordering issue that changed slightly.
>>
>> corbin
>>
>>
>>
>>
>> Thanks,
>>> Ellen
>>>
>>> On Mon, Sep 8, 2008 at 9:52 AM, Stéphane Sudre <[EMAIL PROTECTED]>
>>> wrote:
>>>
>>>
 On Sep 8, 2008, at 12:58 PM, Ellen Chou wrote:

 I have a tree view window that uses NSTableView and NSOutlineView lists
 out

> all the sub folders under user's home directory.  For some reason, this
> window shows the folder contents correctly in Mac OS 10.5.2, but not in
> Mac
> OS 10.4.x running on iMac which is PowerPC host running on Intel Duel
> Core
> CPUs.
>
> It seems to me the Notification/Event was not functioning properly in
> Mac
> OS
> 10.4.x iMac.  I don't get a chance to run on MacBook 10.4.x.  If any
> one
> has
> MacBook Intel CPU running 10.4.x, please let me know.
>
> Anyone run into the similar problem?
>
>
 Are you referring to a specific sample code?

 Which notification/event are you referring to?

 When there's a display strangeness in NSTableView/NSOutlineView, the
 first
 thing to check is that reloadData is called before at least once.



>
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Windows

2008-09-12 Thread Charles Steinman
--- On Fri, 9/12/08, John MacMullin <[EMAIL PROTECTED]> wrote:

> Does the standard Windows menu manage and show all
> application  
> windows?  If so, under what conditions do windows not get
> listed in  
> the pull down?

>From the horse's mouth:

http://developer.apple.com/documentation/Cocoa/Conceptual/WinPanel/Tasks/UsingWindowsMenu.html#//apple_ref/doc/uid/2231-BCIBJBDA

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: NSTableView works in 10.5 but not in 10.4

2008-09-12 Thread Corbin Dunn

I still recommend the same steps to diagnose the problem:

After your model has changed (ie: in awakeFromNib, or wherever you  
initialize things), call -reloadData.


You can test this out by adding a breakpoint in Xcode on [NSTableView  
reloadData]. Have it print the bt, and see when it is called. You  
might be surprised that it isn't when you expect, or it is before your  
model is initialized.


corbin

On Sep 12, 2008, at 3:06 PM, Ellen Chou wrote:


Hi all,

I have the similar problem in 10.4.x with another modaled dialog  
window that only contains NSOutlineView table with 3 columns data.  
I'm pretty sure reloadData is called.  This modaled dialog shows the  
contents correctly in 10.5.2.  Is there a call to refresh the  
display for the modaled dialog window?


Any idea?

Thanks,
Ellen

On Tue, Sep 9, 2008 at 1:53 PM, Ellen Chou <[EMAIL PROTECTED]>  
wrote:

Thanks,

reloadData resolve the problem with 10.4.8.

- Ellen

On Mon, Sep 8, 2008 at 3:20 PM, Corbin Dunn <[EMAIL PROTECTED]> wrote:

On Sep 8, 2008, at 2:36 PM, Ellen Chou wrote:

Hi Stephane,

Indeed, reloadData is not called at all.  But why can it work fine in
10.5.2?

When and where I should call reloadData?


That's easy; after you change your model. When do you initialize  
your arrays, etc? After that point, call reloadData. Possibly in - 
awakeFromNib.


If it is working by chance on Leopard, then it is probably because  
of some ordering issue that changed slightly.


corbin




Thanks,
Ellen

On Mon, Sep 8, 2008 at 9:52 AM, Stéphane Sudre <[EMAIL PROTECTED]>  
wrote:



On Sep 8, 2008, at 12:58 PM, Ellen Chou wrote:

I have a tree view window that uses NSTableView and NSOutlineView  
lists out
all the sub folders under user's home directory.  For some reason,  
this
window shows the folder contents correctly in Mac OS 10.5.2, but not  
in

Mac
OS 10.4.x running on iMac which is PowerPC host running on Intel  
Duel Core

CPUs.

It seems to me the Notification/Event was not functioning properly  
in Mac

OS
10.4.x iMac.  I don't get a chance to run on MacBook 10.4.x.  If any  
one

has
MacBook Intel CPU running 10.4.x, please let me know.

Anyone run into the similar problem?


Are you referring to a specific sample code?

Which notification/event are you referring to?

When there's a display strangeness in NSTableView/NSOutlineView, the  
first

thing to check is that reloadData is called before at least once.






___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: App name from Bundle Identifier?

2008-09-12 Thread Citizen

On 12 Sep 2008, at 22:06, Dave DeLong wrote:

I've been looking inside NSWorkspace, NSBundle, NSApplication,  
NSFileWrapper, etc for some way to get the display name of an  
application from it's bundle identifier, but I can't find anything.   
Is there a way to do this?  For example, if I have  
"com.apple.InterfaceBuilder3", I'd like to get back "Interface  
Builder".


I've just implemented some code to do this:

- (NSString *) name
{
NSBundle * appBundle = [NSBundle bundleWithPath:[self absolutePath]];
	NSString * name = [appBundle  
objectForInfoDictionaryKey:@"CFBundleDisplayName"];
	if (!name) name = [appBundle  
objectForInfoDictionaryKey:@"CFBundleName"]; // this failed for "Gimp"  
so...
	if (!name) name = [appBundle  
objectForInfoDictionaryKey:@"CFBundleExecutable"];
	if (!name) name = [[[self absolutePath]  
stringByDeletingPathExtension] lastPathComponent];

if (!name) name = @"unknown";

return name;
}

- (NSString *) absolutePath
{
	return [[NSWorkspace sharedWorkspace]  
absolutePathForAppBundleWithIdentifier:[self bundleIdentifier]];

}

I don't know if the CFBundleExecutable idea is a good one or not.
You could nest the conditions to make it more efficient (I just went  
for readability).


Regards,
Dave
--
David Kennedy (http://www.zenopolis.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: Windows

2008-09-12 Thread John MacMullin

Ok, thanks.

However, as it stands nothing is being added to the Window menu.

The following code also fails.

IBOutlet NSWindow *testWindowOutlet;

This code is in the awakeFromNib

[testWindowOutlet  setTitle:[[NSBundle mainBundle]  
localizedStringForKey:@"Test Stuff" value:nil table:nil]];
[NSApp addWindowsItem:testWindowOutlet title:[testWindowOutlet title]  
filename:(BOOL)NO];

[testWindowOutlet setExcludedFromWindowsMenu:(BOOL)NO];

After the nib is loaded, I do a makekeyandorderfront on the window,  
which appears with the 'Test Stuff' title, but the window does not  
appear in the Window menu.  As to the NIB, the visible at launch is  
not checked.


Any further suggestions would be greatly appreciated.

John

On Sep 12, 2008, at 3:13 PM, Charles Steinman wrote:


--- On Fri, 9/12/08, John MacMullin <[EMAIL PROTECTED]> wrote:


Does the standard Windows menu manage and show all
application
windows?  If so, under what conditions do windows not get
listed in
the pull down?


From the horse's mouth:

http://developer.apple.com/documentation/Cocoa/Conceptual/WinPanel/Tasks/UsingWindowsMenu.html#/ 
/apple_ref/doc/uid/2231-BCIBJBDA


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

2008-09-12 Thread Peter Ammon


On Sep 12, 2008, at 2:26 PM, John MacMullin wrote:

Does the standard Windows menu manage and show all application  
windows?  If so, under what conditions do windows not get listed in  
the pull down?


On the other hand, it is up to the programmer to manage the list and  
enable and disable windows as they become key and front?


Thanks,


How are you creating the Windows menu?  You need to either use the  
default one that comes with the MainMenu.nib (creating a different  
menu and calling it Windows won't cut it).  If you are making one  
programmatically, use -[NSApp setWindowsMenu:] to bless it as the  
Windows menu.


-Peter
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Can anyone explain this?

2008-09-12 Thread Peter Ammon


On Sep 12, 2008, at 1:31 PM, Roland Silver wrote:


Can anyone explain this?
The value of the expression is apparently different from the value  
of a variable assigned to that expression:


	double pitch = A0Pitch * pow(2.0, ntones/ 
currentTonesPerOctave(voice)) ;
	NSLog(@"expression value: %f", A0Pitch * pow(2.0, ntones/ 
currentTonesPerOctave(voice)));

2008-09-12 16:25:08.095 AttoComp[10566:813] pitch value: 28.305812
NSLog(@"variable value: %f", pitch);
2008-09-12 16:25:08.094 AttoComp[10566:813] pitch variable: nan


A common reason for this is that you do not have a prototype for pow()  
in scope.  Make sure you #include 


-Peter

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Programmatically dismiss NSPopUpButton menu

2008-09-12 Thread Peter Ammon


On Sep 12, 2008, at 1:54 PM, Jeff Johnson wrote:


On Sep 12, 2008, at 3:16 PM, Peter Ammon wrote:


On Sep 12, 2008, at 11:40 AM, Jeff Johnson wrote:

I have a NSView that only appears in a window when a certain  
activity is in progress, and there's an NSPopUpButton in the view  
that acts as a gear menu with actions that relate to the activity  
in progress. The issue is that if the button's menu is still open  
when activity finishes and the view is removed from the window,  
the button is gone but the menu is still displayed, and I can't  
get the menu to dismiss before I remove the view.


The method -[NSPopUpButtonCell dismissPopUp] doesn't seem to work.  
I've filed  on that.


I've tried a bunch of different things to dismiss the popup menu,  
but none of them have worked. I'd greatly appreciate hearing about  
any proven techniques for dismissing the popup menu. Thanks!


-Jeff



You're looking for -[NSMenu cancelTracking].


Ah yes, thanks! That's 10.5-only? I didn't see it because the app  
still supports Tiger, so I was looking in the 10.4 docs. Is there a  
10.4 method for this?


There's no way to do this before Leopard, I'm afraid.




Note that this is somewhat against Mac OS X UI conventions, as  
menus normally don't go away unless the user dismisses them.


Yes, the UI itself is a little unconventional, because the popup  
button itself, along with the containing view, disappears, so I  
didn't want to leave a orphaned menu.


Imagine the user is about to click on a menu item, and the menu  
vanishes and the user triggers whatever was behind it.  Consider  
instead handling the case where the user chooses a menu item after  
the operation has finished with a gentle error message.



Good point about accidentally triggering what's behind the menu. I  
don't know if I want to bother the user with an error message, since  
it's a matter of timing. I could disable all the menu items, though,  
right?


You could disable all the menu items, or in the menu item actions,  
simply do nothing if the operation has finished.  (But make sure their  
target didn't get deallocated.)


-Peter

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSBezierPath lineToPoint: Rate

2008-09-12 Thread Graham Cox


On 13 Sep 2008, at 2:18 am, Ian was here wrote:

I have an app that uses a pen tool. If I move the mouse slowly, the  
free-hand drawing looks smooth, but as I increase the speed at which  
I move the mouse, the line gets bumpy. I am calling lineToPoint: in  
the mouseDragged: method of my view.


Has anyone found a solution to this problem.



The problem is that if you move the mouse quickly, the distance  
between each successive mouse point delivered to your app increases.  
If you simply join successive points with a line, it's bound to get  
bumpy. There's no built-in solution since events are delivered at  
pretty much a fixed maximum rate.


Instead, you could be smarter about how you build your line, using  
curveTo elements to join successive points.


Bear in mind that a curve starts off heading in a direction that is  
tangent to the line between the first point and the first control  
point (cp1), and finishes on the tangent between the last point and  
the last control point (cp2). Using these facts, you can set up the  
positions of cp1 and cp2 according to the direction that the mouse is  
heading in when you sample its position. You can find that out easily  
using the deltaX and deltaY fields of the event. This will also tell  
you the "velocity" of the mouse as well as its direction, so you can  
make the radius of the control point proportional to the velocity. A  
bit of trigonometry is all that is required, and by joining each mouse  
point with the resulting curve, you'll get smooth lines.


hth,

Graham
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newb: Targeting an instance of a class instantiated by a NIB file

2008-09-12 Thread Jonathan Hess


On Sep 12, 2008, at 3:07 PM, Brad Gibbs wrote:

Thanks for the help.  I'm trying to understand your code suggestion  
below.  My app isn't document-based, so I don't think I have a  
document to refer to...  Can I just leave that part out, or will  
things work differently in a non-document-based app?


Ah. That was just an example that I figured would be close enough to  
lead you to the solution that was right for your App. You'll need to  
replace the "windowController] document] mainWindowController]" part  
with whatever series of messages allow you to get a reference back to  
your main view controller.


As for deciding what the right chain of messages is ... At some point  
your view controller probably knows about some object, that knows some  
other object, that knows another object ... that finally knows your  
main window controller. If there isn't some chain of relationships you  
can follow through your objects to get from your view controller to  
your window controller, you could introduce one. Once you've done  
that, you'll use that path to get from self, the view controller, to  
your main window controller.


 I've also re CC'd the list because I think this thread will be  
interesting to new cocoa developers searching through the list history  
for help -

Jon Hess




The bit I wrote about the responder chain was in response to Jamie  
Hardt's suggestion that I use the responder chain (which I couldn't  
get to work, either).



On Sep 12, 2008, at 2:43 PM, Jonathan Hess wrote:



On Sep 12, 2008, at 2:25 PM, Brad Gibbs wrote:


If I'm reading your mail correctly, I've tried that without success.

I have a MainWindowController controlling MainWindow.  On  
MainWindow.xib is a button which launches another window  
(MainMenu,xib) with a window controller  
(MainMenuWindowController.m).  A couple of NSViewControllers down  
is a view with the buttons in question.


I've tried creating an instance of MainWindowController in that  
view's NSViewController (declaring MainWindowController  
*iMainWindowController in the interface, using @property and  
@synthesize and then calling iMainWindowController =  
[[MainWindowController alloc] init] in the NSViewController's  
implementation section).


The problem is that this creates a new 'MainWindowController'. The  
object you get in response to [[MainWindowController alloc] init]  
is unrelated to the one previously created.




I can tell the method is being called by an NSLog statement posted  
to the Console, but the view doesn't swap in.  I'm assuming this  
is because I've programmatically created another instance of the  
MainWindowController class in the NSViewController and I'm  
targeting that instance with the buttons, rather than the instance  
created at launch, which is controlling the MainWindow.


Exactly.

Calling a method on the MainWindowController instance created by  
the NSViewController would still cause the log file to print the  
message without swapping in the view on the instance of the Main  
Window created when I launch the app.  So, I'm left to assume that  
I need to target the instance created at launch.


Yep.



According to the Event Handling Guide:
 If an NSWindowController object is managing the window, it  
becomes the final next responder.


Is this going to be a problem, since the NSViewController with the  
button code is underneath its own NSWindowController?  Would the  
responder chain just stop there and so that messages wouldn't make  
their way over and up to the MainWindowController?


The method I suggested is independent of the responder chain. So  
this won't come into play. If you follow the other suggestion, this  
will be relevant.


If you choose to peruse my suggestion further, you'll need to make  
a way to find the original MainWindowController from the code  
inside of your view controller. If your document is holding onto a  
reference to the main window controller, perhaps your view  
controller can do something like 'self window]  
windowController] document] mainWindowController]'.


Good Luck -
Jon Hess



Thanks again.

Brad


On Sep 12, 2008, at 1:38 PM, Jonathan Hess wrote:


Hey Brad -

So it sounds like you have two controllers, A, and B, and they  
each have their own NIB. Sound like you're on the right track.  
Now you want to have an action in B's NIB affect controller A.  
Does controller B have an instance variable, or other mechanism,  
for referencing controller A? If so, you could put an action  
method on controller B and have that be the target of your button  
in NIB B. The implementation of that action can then call a  
method on controller A.


Jon Hess


On Sep 12, 2008, at 12:17 PM, Brad Gibbs wrote:

I'm working on an application with a single main window and a  
number of views and view controllers.  I have a navigation  
window that pops up and allows users to set preferences and also  
switch views in the main portion of the app's main window.


I wan

Re: clearing NSView outside of drawRect:

2008-09-12 Thread Graham Cox


On 13 Sep 2008, at 1:29 am, Chinh Nguyen wrote:

My selection is several pixels behind my mouse as I'm dragging it  
when I use setNeedsDisplay:



This suggests you're handling the drag loop incorrectly. There's no  
reason this should be the case when using setNeedDisplay: - if you  
organise your code right, it will work fine, and no extra tricks like  
using your own tracking loop are needed.


Maybe you could show your code?

Normally, for dragging a selection rect I use the following basic  
approach:


1. On mouse down, make a note of the initial point in an ivar. This is  
the "anchor".
2. On mouse dragged, form a rect from two corner points, being the  
current mouse and the previously recorded anchor. Save this in an  
ivar. Invalidate that rect with setNeedsDisplayInRect:.
3. On drawRect:, use the rect calculated in (2) to draw the selection  
highlight as you wish. If you are using the rect to select objects,  
you can also pass it to other methods that find which objects it  
touches or encloses.


The above should keep up with the mouse with no noticeable lag. If  
your "detect selected objects" method is very slow it may stutter  
somewhat, but that's a different area for optimisation - the  
fundamental approach to dragging the box doesn't need to change.



hth,


Graham
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Windows

2008-09-12 Thread John MacMullin

I am using the standard, default Window menu.

John
On Sep 12, 2008, at 4:04 PM, Peter Ammon wrote:



On Sep 12, 2008, at 2:26 PM, John MacMullin wrote:

Does the standard Windows menu manage and show all application  
windows?  If so, under what conditions do windows not get listed in  
the pull down?


On the other hand, it is up to the programmer to manage the list  
and enable and disable windows as they become key and front?


Thanks,


How are you creating the Windows menu?  You need to either use the  
default one that comes with the MainMenu.nib (creating a different  
menu and calling it Windows won't cut it).  If you are making one  
programmatically, use -[NSApp setWindowsMenu:] to bless it as the  
Windows menu.


-Peter


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: App name from Bundle Identifier?

2008-09-12 Thread Rainer Brockerhoff
At 17:06 -0700 12/09/08, [EMAIL PROTECTED] wrote:
>From: Jonathan Hess <[EMAIL PROTECTED]>
>References: <[EMAIL PROTECTED]>
>In-Reply-To: <[EMAIL PROTECTED]>
>Date: Fri, 12 Sep 2008 14:34:59 -0700
>Message-ID: <[EMAIL PROTECTED]>
>...
>Before displaying a localized name for your bundle, the Finder compares the 
>value of this key against the actual name of your bundle in the file system. 
>If the two names match, the Finder proceeds to display the localized name from 
>the appropriate InfoPlist.strings file of your bundle. If the names do not 
>match, the Finder displays the file-system name.

Just as a heads-up/quibble, localized bundle names work only for .apps, not for 
.bundles (or any other common bundle extension that I tested against). I filed 
rdar://6209849 ...

-- 
Rainer Brockerhoff  <[EMAIL PROTECTED]>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
 In their own business even sages err."
Weblog: http://www.brockerhoff.net/bb/viewtopic.php
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: clearing NSView outside of drawRect:

2008-09-12 Thread Graham Cox


On 13 Sep 2008, at 10:21 am, Graham Cox wrote:

 If you are using the rect to select objects, you can also pass it  
to other methods that find which objects it touches or encloses.



To be clear - of course you'd do this in step (2), not step (3), then  
*draw* the feedback of being in a selected state in step (3).


cheers, Graham
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: App name from Bundle Identifier?

2008-09-12 Thread Jason Coco


On Sep 12, 2008, at 18:26 , Citizen wrote:


On 12 Sep 2008, at 22:06, Dave DeLong wrote:

I've been looking inside NSWorkspace, NSBundle, NSApplication,  
NSFileWrapper, etc for some way to get the display name of an  
application from it's bundle identifier, but I can't find  
anything.  Is there a way to do this?  For example, if I have  
"com.apple.InterfaceBuilder3", I'd like to get back "Interface  
Builder".


I've just implemented some code to do this:

- (NSString *) name
{
NSBundle * appBundle = [NSBundle bundleWithPath:[self absolutePath]];
	NSString * name = [appBundle  
objectForInfoDictionaryKey:@"CFBundleDisplayName"];
	if (!name) name = [appBundle  
objectForInfoDictionaryKey:@"CFBundleName"]; // this failed for  
"Gimp" so...
	if (!name) name = [appBundle  
objectForInfoDictionaryKey:@"CFBundleExecutable"];
	if (!name) name = [[[self absolutePath]  
stringByDeletingPathExtension] lastPathComponent];

if (!name) name = @"unknown";

return name;
}

- (NSString *) absolutePath
{
	return [[NSWorkspace sharedWorkspace]  
absolutePathForAppBundleWithIdentifier:[self bundleIdentifier]];

}

I don't know if the CFBundleExecutable idea is a good one or not.
You could nest the conditions to make it more efficient (I just went  
for readability).


I think that the file manager way is the better choice because you get  
the localization for free... (assuming the app has a localized name).

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: when should my NSWindowController be released?

2008-09-12 Thread Ken Thomases

On Sep 12, 2008, at 4:44 PM, Paul Archibald wrote:

So, what is the general outline of properly allocating,  
initializing and deallocating an application and its elements? Can  
someone point me to the right documentation? I can't seem to find  
reference to this subject.


Here's the Memory Management Guide: http://developer.apple.com/ 
documentation/Cocoa/Conceptual/MemoryMgmt/index.html


Cocoa doesn't bother doing a full release/dealloc of your application  
object (and the things it owns) at application termination.  The  
principle is that the OS is about to cleanup the whole process's  
address space in one fell swoop, so there's no point in doing it  
piecemeal first.


If you need to do work other than memory management (e.g. cleaning up  
other types of resources), then -applicationWillTerminate: is the  
right place to do it.


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: when should my NSWindowController be released?

2008-09-12 Thread Jamie Hardt

On Sep 12, 2008, at 5:53 PM, Ken Thomases wrote:

Cocoa doesn't bother doing a full release/dealloc of your  
application object (and the things it owns) at application  
termination.  The principle is that the OS is about to cleanup the  
whole process's address space in one fell swoop, so there's no point  
in doing it piecemeal first.



I think his question, and I've wondered about this too, is when do  
NSWindowControllers owned by an NSDcoument get deallocated?  In the  
past I've put breakpoints on [NSWindowController dealloc] and have  
open and closed documents like crazy, and -dealloc never seems to get  
called:


On Sep 12, 2008, at 2:44 PM, Paul Archibald wrote:

My question is about creating and destroying my controller. I have - 
initMyController and -windowDidLoad methods, which handle setting up  
my controller, but for some reason my -dealloc method is never  
called, even when the main app quits. In fact, the -dealloc method  
in the main controller is never called either. (I did not work on  
the main controller code.)


Jamie Hardt
The Sound Department
http://www.soundepartment.com/
http://www.imdb.com/name/nm0362504/

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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, Bindings, NSSearchField, and NSPopUpButton

2008-09-12 Thread Steve Mykytyn
I'm displaying a list of 100,000 or so global locations in an  
NSTableView, using an NSSearchField to help the user zero in on  
desired locations by street address, city, state, country, etc.  It  
all works fine using Core Data plus bindings.  And best of all no  
interface code...


It would be handy to add an NSPopupButton with the list of countries  
to optionally restrict the search to a specific country while looking  
for a city name in the searchfield, say.  Can't seem to find any  
relevant examples of this kind of thing with Core Data + Bindings,  
where two interface items are controlling the search.  I prefer to  
keep the interface code to zero if possible.


Suggestions on where to look or how to proceed?
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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, Bindings, NSSearchField, and NSPopUpButton

2008-09-12 Thread Jamie Hardt

On Sep 12, 2008, at 6:09 PM, Steve Mykytyn wrote:

It would be handy to add an NSPopupButton with the list of countries  
to optionally restrict the search to a specific country while  
looking for a city name in the searchfield, say.  Can't seem to find  
any relevant examples of this kind of thing with Core Data +  
Bindings, where two interface items are controlling the search.  I  
prefer to keep the interface code to zero if possible.



Hi-

You will need an NSArrayController to hold a list of countries.  You  
should be able to create it by binding to your Locations array's  
"[EMAIL PROTECTED]".  That gives you a list of  
countries to populate the NSArrayController for Countries, and then  
you make the popup button's selection bound to a filter predicate on  
your Locations array controller.


Jamie Hardt
The Sound Department
http://www.soundepartment.com/
http://www.imdb.com/name/nm0362504/

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Newb: Targeting an instance of a class instantiated by a NIB file

2008-09-12 Thread Brad Gibbs
I run into a stumbling block once I get to the first  
NSWindowController, whether I'm trying your method, or trying to use  
the Responder Chain, as Jamie suggested.  I get what you're suggesting  
and I tried going that route before making the original post, but I  
don't know how to go from the NSWindowController that contains the  
buttons over to the other NSWindowController that contains the view  
switching code.  A button on the MainWindowController launches the  
MainMenuWindowController, but the two don't have any kind of direct  
relationship through a hierarchy.  So, when I use  
[self.view.window.windowController], i can get to the controller of  
the view containing the buttons, but I don't where to go from there,  
given that there is no direct relationship between that window  
controller and anything on the main window or its controller.



I tried to make the MainMenuWindow a child of the MainWindow, and  
while that did allow the buttons to control the view switching, it  
caused all sorts of other problems, since calls such as  
[self.view.window close] that were intended to close just the  
MainMenuWindow began closing both windows.


I tried:

	[self.view.window.parentWindow.windowController removeChildWindow: 
[self.view.window]];

[self.view.window close];

but XCode spit out an error -- I suppose XCode sees this as self- 
referential?


So, the problem remains...

As far as the responder chain goes, the message goes up from the  
NSViewController containing the buttons through its window, to that  
window's controller and then to NSApp.  I don't know how to cause it  
to jump to the main window's window controller.




On Sep 12, 2008, at 5:15 PM, Jonathan Hess wrote:



On Sep 12, 2008, at 3:07 PM, Brad Gibbs wrote:

Thanks for the help.  I'm trying to understand your code suggestion  
below.  My app isn't document-based, so I don't think I have a  
document to refer to...  Can I just leave that part out, or will  
things work differently in a non-document-based app?


Ah. That was just an example that I figured would be close enough to  
lead you to the solution that was right for your App. You'll need to  
replace the "windowController] document] mainWindowController]" part  
with whatever series of messages allow you to get a reference back  
to your main view controller.


As for deciding what the right chain of messages is ... At some  
point your view controller probably knows about some object, that  
knows some other object, that knows another object ... that finally  
knows your main window controller. If there isn't some chain of  
relationships you can follow through your objects to get from your  
view controller to your window controller, you could introduce one.  
Once you've done that, you'll use that path to get from self, the  
view controller, to your main window controller.


 I've also re CC'd the list because I think this thread will be  
interesting to new cocoa developers searching through the list  
history for help -

Jon Hess




The bit I wrote about the responder chain was in response to Jamie  
Hardt's suggestion that I use the responder chain (which I couldn't  
get to work, either).



On Sep 12, 2008, at 2:43 PM, Jonathan Hess wrote:



On Sep 12, 2008, at 2:25 PM, Brad Gibbs wrote:

If I'm reading your mail correctly, I've tried that without  
success.


I have a MainWindowController controlling MainWindow.  On  
MainWindow.xib is a button which launches another window  
(MainMenu,xib) with a window controller  
(MainMenuWindowController.m).  A couple of NSViewControllers down  
is a view with the buttons in question.


I've tried creating an instance of MainWindowController in that  
view's NSViewController (declaring MainWindowController  
*iMainWindowController in the interface, using @property and  
@synthesize and then calling iMainWindowController =  
[[MainWindowController alloc] init] in the NSViewController's  
implementation section).


The problem is that this creates a new 'MainWindowController'. The  
object you get in response to [[MainWindowController alloc] init]  
is unrelated to the one previously created.




I can tell the method is being called by an NSLog statement  
posted to the Console, but the view doesn't swap in.  I'm  
assuming this is because I've programmatically created another  
instance of the MainWindowController class in the  
NSViewController and I'm targeting that instance with the  
buttons, rather than the instance created at launch, which is  
controlling the MainWindow.


Exactly.

Calling a method on the MainWindowController instance created by  
the NSViewController would still cause the log file to print the  
message without swapping in the view on the instance of the Main  
Window created when I launch the app.  So, I'm left to assume  
that I need to target the instance created at launch.


Yep.



According to the Event Handling Guide:
 If an NSWindowController object is managing the 

Re: Newb: Targeting an instance of a class instantiated by a NIB file

2008-09-12 Thread Bill Bumgarner


On Sep 12, 2008, at 7:08 PM, Brad Gibbs wrote:
	[self.view.window.parentWindow.windowController removeChildWindow: 
[self.view.window]];


[self.view.window] doesn't make any sense.

b.bum




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]

Bug with -changeAttributes: in NSFontManager/Font Panel?

2008-09-12 Thread Graham Cox
I'm using the Font Panel via NSFont Manager to change text attributes  
through a modal panel (in fact a sheet).


I can change the font OK, as using -setTarget: I can set the target of  
the font manager to my modal panel. However, I never get the call to - 
changeAttributes:, so all the stuff such as colour and shadow that the  
Font Panel has doesn't function.


Is this a bug, or am I doing something wrong? If it is a bug, can  
anyone suggest a workaround?


My code is pretty simple:

When my modal sheet is initialized, I set up the font manager thusly:

	// establish the connection to the font panel and update it to match  
the current font/text attributes


	NSDictionary*	textAttributes = [settings  
objectForKey:kDKOMapGridHorizontalAnnotationTextAttributes];

NSFont* font = [textAttributes 
objectForKey:NSFontAttributeName];

[[NSFontManager sharedFontManager] setTarget:self];
	[[NSFontManager sharedFontManager]  
setSelectedAttributes:textAttributes isMultiple:NO];

[[NSFontManager sharedFontManager] setSelectedFont:font isMultiple:NO];

(where 'settings' is a dictionary of a whole raft of things, including  
the text attributes of the text I want to change via the font panel)


and my -changeFont: and -changeAttributes: methods look like:

- (IBAction)changeFont:(id) sender
{
// received changeFont message from font panel

NSFont* newFont, *oldFont;
	NSMutableDictionary* textAttributes = [[mSettings  
objectForKey:kDKOMapGridHorizontalAnnotationTextAttributes]  
mutableCopy];


oldFont = [textAttributes objectForKey:NSFontAttributeName];
newFont = [sender convertFont:oldFont];

[textAttributes setObject:newFont forKey:NSFontAttributeName];

	[mSettings setObject:textAttributes  
forKey:kDKOMapGridHorizontalAnnotationTextAttributes];
	[mSettings setObject:textAttributes  
forKey:kDKOMapGridVerticalAnnotationTextAttributes];


[textAttributes release];
[self conditionallyPreview];
}


- (IBAction)changeAttributes:(id) sender
{
NSLog(@"received -changeAttributes: from <%@>", sender );   

	NSDictionary* textAttributes = [mSettings  
objectForKey:kDKOMapGridHorizontalAnnotationTextAttributes];
	NSDictionary*	newAttributes = [sender  
convertAttributes:textAttributes];


	[mSettings setObject:newAttributes  
forKey:kDKOMapGridHorizontalAnnotationTextAttributes];
	[mSettings setObject:newAttributes  
forKey:kDKOMapGridVerticalAnnotationTextAttributes];

[self conditionallyPreview];
}


The call to changeAttributes is never logged.

It seems as if [NSFontManager setTarget] applies only to the  
changeFont: message and not to changeAttributes:. This appears to be a  
bug, but there may be some good reason for it. Workaround?


tia,


Graham

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newb: Targeting an instance of a class instantiated by a NIB file

2008-09-12 Thread Jonathan Hess

Hey Brad -

What code is responsible for creating each of the two window  
controllers? Perhaps that code could tell each of the window  
controllers about each other. Or, it sounds like your application  
isn't document based. Are there ever multiple instances of the two  
windows you're currently working with? If not, perhaps your  
NSApplication subclass, or application delegate, should have a  
reference both window controllers and you could use that object to be  
the missing link.


Jon Hess

On Sep 12, 2008, at 7:08 PM, Brad Gibbs wrote:

I run into a stumbling block once I get to the first  
NSWindowController, whether I'm trying your method, or trying to use  
the Responder Chain, as Jamie suggested.  I get what you're  
suggesting and I tried going that route before making the original  
post, but I don't know how to go from the NSWindowController that  
contains the buttons over to the other NSWindowController that  
contains the view switching code.  A button on the  
MainWindowController launches the MainMenuWindowController, but the  
two don't have any kind of direct relationship through a hierarchy.   
So, when I use [self.view.window.windowController], i can get to the  
controller of the view containing the buttons, but I don't where to  
go from there, given that there is no direct relationship between  
that window controller and anything on the main window or its  
controller.



I tried to make the MainMenuWindow a child of the MainWindow, and  
while that did allow the buttons to control the view switching, it  
caused all sorts of other problems, since calls such as  
[self.view.window close] that were intended to close just the  
MainMenuWindow began closing both windows.


I tried:

	[self.view.window.parentWindow.windowController removeChildWindow: 
[self.view.window]];

[self.view.window close];

but XCode spit out an error -- I suppose XCode sees this as self- 
referential?


So, the problem remains...

As far as the responder chain goes, the message goes up from the  
NSViewController containing the buttons through its window, to that  
window's controller and then to NSApp.  I don't know how to cause it  
to jump to the main window's window controller.




On Sep 12, 2008, at 5:15 PM, Jonathan Hess wrote:



On Sep 12, 2008, at 3:07 PM, Brad Gibbs wrote:

Thanks for the help.  I'm trying to understand your code  
suggestion below.  My app isn't document-based, so I don't think I  
have a document to refer to...  Can I just leave that part out, or  
will things work differently in a non-document-based app?


Ah. That was just an example that I figured would be close enough  
to lead you to the solution that was right for your App. You'll  
need to replace the "windowController] document]  
mainWindowController]" part with whatever series of messages allow  
you to get a reference back to your main view controller.


As for deciding what the right chain of messages is ... At some  
point your view controller probably knows about some object, that  
knows some other object, that knows another object ... that finally  
knows your main window controller. If there isn't some chain of  
relationships you can follow through your objects to get from your  
view controller to your window controller, you could introduce one.  
Once you've done that, you'll use that path to get from self, the  
view controller, to your main window controller.


 I've also re CC'd the list because I think this thread will be  
interesting to new cocoa developers searching through the list  
history for help -

Jon Hess




The bit I wrote about the responder chain was in response to Jamie  
Hardt's suggestion that I use the responder chain (which I  
couldn't get to work, either).



On Sep 12, 2008, at 2:43 PM, Jonathan Hess wrote:



On Sep 12, 2008, at 2:25 PM, Brad Gibbs wrote:

If I'm reading your mail correctly, I've tried that without  
success.


I have a MainWindowController controlling MainWindow.  On  
MainWindow.xib is a button which launches another window  
(MainMenu,xib) with a window controller  
(MainMenuWindowController.m).  A couple of NSViewControllers  
down is a view with the buttons in question.


I've tried creating an instance of MainWindowController in that  
view's NSViewController (declaring MainWindowController  
*iMainWindowController in the interface, using @property and  
@synthesize and then calling iMainWindowController =  
[[MainWindowController alloc] init] in the NSViewController's  
implementation section).


The problem is that this creates a new 'MainWindowController'.  
The object you get in response to [[MainWindowController alloc]  
init] is unrelated to the one previously created.




I can tell the method is being called by an NSLog statement  
posted to the Console, but the view doesn't swap in.  I'm  
assuming this is because I've programmatically created another  
instance of the MainWindowController class in the  
NSViewController and I'm t

Re: Newb: Targeting an instance of a class instantiated by a NIB file

2008-09-12 Thread Brad Gibbs
OK  XCode doesn't put up any errors or any warnings for this code  
and the app works as intended.  The code is in an NSViewController, so  
I was targeting the view controller's view and then the view's  
window.  What is the correct approach?




On Sep 12, 2008, at 7:09 PM, Bill Bumgarner wrote:



On Sep 12, 2008, at 7:08 PM, Brad Gibbs wrote:
	[self.view.window.parentWindow.windowController removeChildWindow: 
[self.view.window]];


[self.view.window] doesn't make any sense.

b.bum




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Newb: Targeting an instance of a class instantiated by a NIB file

2008-09-12 Thread Brad Gibbs

Hey Jon,

It is a non-document-based app.  Only one instance of each window  
should ever be open at one time.


I have an AppController class that is the NSApp delegate.  In the  
AppController's awakeFromNib I alloc the MainWindowController and  
initWithNib.  In the MainWindowController, I have an IBAction for a  
button that allocs the MainMenuWindowController and initWithNib's the  
MainMenu (which I'm implementing with a HUD panel and the BGHUDAppKit).


I'll have to look into putting some references in the AppController.


Brad


On Sep 12, 2008, at 7:52 PM, Jonathan Hess wrote:


Hey Brad -

What code is responsible for creating each of the two window  
controllers? Perhaps that code could tell each of the window  
controllers about each other. Or, it sounds like your application  
isn't document based. Are there ever multiple instances of the two  
windows you're currently working with? If not, perhaps your  
NSApplication subclass, or application delegate, should have a  
reference both window controllers and you could use that object to  
be the missing link.


Jon Hess



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Transparent Background for a Progress Indicator (NSView)

2008-09-12 Thread Michael Ash
On Fri, Sep 12, 2008 at 3:25 PM, Simon <[EMAIL PROTECTED]> wrote:
> Hi guys,
>
> This is a quick question I hope! What's the most efficient way to make the
> progress indicator background transparent (I've got a screen shot of a quick
> test app[1])? Is there away to do this without redrawing the gradient in the
> background? I'm assuming that I could try and find out the dirty area if I
> need to...
>
> Sorry in advance if I'm missing something, but your help will be greatly
> appreciated.

You should ignore the parameter to your drawRect: method:

http://www.cocoadev.com/index.pl?DrawRect

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: when should my NSWindowController be released?

2008-09-12 Thread Michael Ash
On Fri, Sep 12, 2008 at 9:02 PM, Jamie Hardt <[EMAIL PROTECTED]> wrote:
> On Sep 12, 2008, at 5:53 PM, Ken Thomases wrote:
>
>> Cocoa doesn't bother doing a full release/dealloc of your application
>> object (and the things it owns) at application termination.  The principle
>> is that the OS is about to cleanup the whole process's address space in one
>> fell swoop, so there's no point in doing it piecemeal first.
>
>
> I think his question, and I've wondered about this too, is when do
> NSWindowControllers owned by an NSDcoument get deallocated?  In the past
> I've put breakpoints on [NSWindowController dealloc] and have open and
> closed documents like crazy, and -dealloc never seems to get called:

The NSDocument and any/all associated NSWindowControllers should be
closed and then deallocated when the document itself is closed. If
your window controllers aren't being deallocated then you have a
memory management bug somewhere.

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: Newb: Targeting an instance of a class instantiated by a NIB file

2008-09-12 Thread Bill Bumgarner

On Sep 12, 2008, at 8:24 PM, Brad Gibbs wrote:
OK  XCode doesn't put up any errors or any warnings for this  
code and the app works as intended.  The code is in an  
NSViewController, so I was targeting the view controller's view and  
then the view's window. What is the correct approach?


I was referring explicitly to the '[self.view.window]' sub- 
expression.  That isn't valid.  I'm not even sure why it compiles,  
frankly.


If you were trying to pass the window to -removeChildWindow:, it'd  
look something like:


[self.view.window.parentWindow.windowController removeChildWindow:  
self.view.window];



On Sep 12, 2008, at 7:09 PM, Bill Bumgarner wrote:

On Sep 12, 2008, at 7:08 PM, Brad Gibbs wrote:
	[self.view.window.parentWindow.windowController removeChildWindow: 
[self.view.window]];






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

2008-09-12 Thread has

Georg Seifert wrote:


 [NSView dataWithEPSInsideRect:] does not seem to help, unless I
build a dummy view, draw in it and then use this method.


I believe that's the general idea. An NSBezierPath instance by itself  
doesn't really do anything unless/until you draw it into a suitable  
graphics context. Read the Cocoa Drawing Guide; in particular, the  
'Creating Graphics Contexts' chapter.



but this seems to be quite complicated.



I'm no graphics guru (so try not to laugh), but here's a simple example:


/// CustomView.h ///

#import 

@interface CustomView : NSView {
}

- (NSEPSImageRep *)epsImageRep;

@end


/// CustomView.m ///

#import "CustomView.h"

@implementation CustomView

- (void)drawRect:(NSRect)rect {
	// do all your drawing here... e.g. to draw a black rectangle in  
middle of view:

[[NSBezierPath bezierPathWithRect: NSMakeRect(10, 10, 20, 20)] fill];
}

- (NSEPSImageRep *)epsImageRep {
NSData* theData = [self dataWithEPSInsideRect: [self bounds]];
return [NSEPSImageRep imageRepWithData: theData];
}

@end


/// main.m ///

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

// create a custom view of the desired size
	CustomView *view = [[CustomView alloc] initWithFrame: NSMakeRect(0,  
0, 40, 40)];


// extract an EPS image rep from it
NSEPSImageRep *epsRep = [view epsImageRep];

// do some stuff with the EPS image rep here... e.g. to write to file:
	[[epsRep EPSRepresentation] writeToFile: @"/Users/foobar/test.eps"  
atomically: NO];


[view release];
[pool release];
return 0;
}


HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
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: when should my NSWindowController be released?

2008-09-12 Thread Markus Spoettl

On Sep 12, 2008, at 8:44 PM, Michael Ash wrote:

The NSDocument and any/all associated NSWindowControllers should be
closed and then deallocated when the document itself is closed. If
your window controllers aren't being deallocated then you have a
memory management bug somewhere.



I have observed the following in my application:

When the document is closed while the application keeps running, my  
document, window controller and dependent windows get deallocated as  
expected.


However, when the document closes while during application  
termination, the document and window controller get deallocated, but  
the document window are not (as a result lots of other things don't  
get deallocated).


The fact that the document and all it's dependent structures get  
deallocated in the first case tells me that my memory management is  
working correctly.


I have - maybe incorrectly - come to the conclusion that the system/ 
Cocoa retains windows and doesn't release them during app shutdown. Am  
I mistaken?


Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]