Re: Basic Core Animation question

2008-04-13 Thread Greg Sabo
Ah! It compiled. Thank you very much! And thanks to Michael for putting
together the sample project.

Now to get the CALayer to draw a path. Most of the documentation I've seen
suggest to do this with a delegate function, is that correct? Here is the
delegate function I've written (a.k.a. copied from another program):

//
- (void)drawLayer:(CALayer *)theLayer
inContext:(CGContextRef)theContext {
CGMutablePathRef thePath = CGPathCreateMutable();

CGPathMoveToPoint(thePath,NULL,15.0f,15.f);
CGPathAddCurveToPoint(thePath,
  NULL,
  15.f,250.0f,
  295.0f,250.0f,
  295.0f,15.0f);

CGContextBeginPath(theContext);
CGContextAddPath(theContext, thePath );

CGContextSetLineWidth(theContext, 1);

CGContextSetRGBStrokeColor(theContext,0.0,0.0,1.0,1.0);


CGContextStrokePath(theContext);
}
//**

I'm just seeing the black background right now.
Again, thanks for your help and sorry I'm such a pain :)

On Sun, Apr 13, 2008 at 1:29 AM, Michael Watson <[EMAIL PROTECTED]>
wrote:

> I noticed:
>
>  //GameBoard.h*
> > #import 
> > #import 
> >
>
> You've added QuartzCore.framework, but Quartz.h isn't the top-level header
> for QuartzCore. You're importing a header in a framework you aren't linking
> to.
>
> Either link to Quartz.framework and import , or link to
> QuartzCore.framework and import .
>
>
> --
> m-s
>
>
>
> On 13 Apr, 2008, at 02:17, Greg Sabo wrote:
>
> > Hmm, I just added it, and I still get the same linking error. Any other
> > ideas?
> >
> > I could probably use an example project which successfully uses
> > CALayers,
> > too. I can't find any on the net that are helpful.
> >
> >
> > On Sat, Apr 12, 2008 at 7:36 PM, Michael Vannorsdel <[EMAIL PROTECTED]>
> > wrote:
> >
> >  Did you put the QuartzCore framework in your project Frameworks?  The
> > > linker needs to know about QuartzCore before it can find the CALayer
> > > class
> > > symbols.
> > >
> > >
> > > On Apr 12, 2008, at 5:58 PM, Greg Sabo wrote:
> > >
> > > I'm a Compsci student trying to learn Cocoa development, and I'm
> > > trying
> > >
> > > > to
> > > > write a simple program using Core Animation, but I'm having a hard
> > > > time
> > > > getting it to work. I just need someone to tell me what I'm doing
> > > > wrong
> > > > so I
> > > > can move on and screw up something else :)
> > > > Thanks, and I apologize for the newbie question!
> > > >
> > > >
> > > ___
> > >
> > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> > >
> > > Please do not post admin requests or moderator comments to the list.
> > > Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> > >
> > > Help/Unsubscribe/Update your Subscription:
> > > http://lists.apple.com/mailman/options/cocoa-dev/gregsabo%40gmail.com
> > >
> > > This email sent to [EMAIL PROTECTED]
> > >
> > >  ___
> >
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/gregsabo%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Basic Core Animation question

2008-04-13 Thread Michael Vannorsdel

Are you calling the CALayer's setNeedsDisplay to trigger a redraw?


On Apr 13, 2008, at 1:01 AM, Greg Sabo wrote:

Ah! It compiled. Thank you very much! And thanks to Michael for  
putting

together the sample project.

Now to get the CALayer to draw a path. Most of the documentation  
I've seen
suggest to do this with a delegate function, is that correct? Here  
is the

delegate function I've written (a.k.a. copied from another program):


___

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

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


NSTextField vertical sizeToFit

2008-04-13 Thread Jeff
Any way to take an NSTextField containing some amount of text, and resize it
vertically so all the text fits within the frame? The sizeToFit message
seems to do this, except on the horizontal axis.
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: struct problem

2008-04-13 Thread Dean Ritchie


On Apr 12, 2008, at 8:30 PM, Ben Lachman wrote:

In general the naming convention used in Objective-C is that class  
names start with capitals and variable names start with lower-case  
characters (both use bumpy case which I think you know).  For  
instance NSWindow (class) and aWindow (variable).  However in your  
code you have LASize, which looks a whole lot like NSSize (which  
happens to be a struct).  However you're assigning sender to it  
which is of type id.  This introduces some confusion, since you  
assumedly assign an object variable to something that looks very  
much like a struct type.  This may not be a bug (we don't know what  
type sender or LASize are so it's hard to say), but it leaves the  
code nearly unreadable for the casual observer.  If you want someone  
to help you out, try to post more clear code.  In a more general  
sense, it's good to write code that follows the general naming  
conventions anyway since if you ever have to share your code or go  
just back and read it in a year you'll have less work understanding  
it.


Thanks for the advice--I'll try to follow it more carefully.  I should  
have included the declarations, in my .h file, to make the example  
clearer to all.


In the meantime, I have gone on to explore the question, and I may  
have discovered a problem with the debugger.  Perhaps the list can  
advise me:


If I insert the following code into my program, with a breakpoint  
immediately following, the debugger shows ridiculous values for the  
elements of aRect.


NSRect aRect;
aRect.origin.x = 310.0;
aRect.origin.y = 15.0;
aRect.size.width = 100.0;
aRect.size.height= 100.0;

When I sent my original posting, I was trying to discover how the  
structure had been corrupted.  It appears to me now that it hadn't  
been corrupted at all, but was being misreported by GDB.  Should I  
submit a bug report?


Dean Ritchie
___

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

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

2008-04-13 Thread Thomas Backman
Are you running the app in debug mode? I've made the mistake of trying  
to debug in "release" mode a few times, and it often shows some insane  
values for variables.


/Thomas

On Apr 13, 2008, at 2:21 PM, Dean Ritchie wrote:


On Apr 12, 2008, at 8:30 PM, Ben Lachman wrote:

In general the naming convention used in Objective-C is that class  
names start with capitals and variable names start with lower-case  
characters (both use bumpy case which I think you know).  For  
instance NSWindow (class) and aWindow (variable).  However in your  
code you have LASize, which looks a whole lot like NSSize (which  
happens to be a struct).  However you're assigning sender to it  
which is of type id.  This introduces some confusion, since you  
assumedly assign an object variable to something that looks very  
much like a struct type.  This may not be a bug (we don't know what  
type sender or LASize are so it's hard to say), but it leaves the  
code nearly unreadable for the casual observer.  If you want  
someone to help you out, try to post more clear code.  In a more  
general sense, it's good to write code that follows the general  
naming conventions anyway since if you ever have to share your code  
or go just back and read it in a year you'll have less work  
understanding it.


Thanks for the advice--I'll try to follow it more carefully.  I  
should have included the declarations, in my .h file, to make the  
example clearer to all.


In the meantime, I have gone on to explore the question, and I may  
have discovered a problem with the debugger.  Perhaps the list can  
advise me:


If I insert the following code into my program, with a breakpoint  
immediately following, the debugger shows ridiculous values for the  
elements of aRect.


NSRect aRect;
aRect.origin.x = 310.0;
aRect.origin.y = 15.0;
aRect.size.width = 100.0;
aRect.size.height= 100.0;

When I sent my original posting, I was trying to discover how the  
structure had been corrupted.  It appears to me now that it hadn't  
been corrupted at all, but was being misreported by GDB.  Should I  
submit a bug report?


Dean Ritchie
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/serenity 
%40exscape.org


This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: struct problem

2008-04-13 Thread Dean Ritchie


On Apr 13, 2008, at 5:31 AM, Thomas Backman wrote:

Are you running the app in debug mode? I've made the mistake of  
trying to debug in "release" mode a few times, and it often shows  
some insane values for variables.


This is news to me.  How can I tell?  In the Run menu, the Go item is  
Go(Debug).  What is this "release" mode and how can I avoid (or  
properly use) it?


Dean Ritchie
___

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

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

2008-04-13 Thread Jerry Krinock

On 2008 Apr, 13, at 1:38, Jeff wrote:

Any way to take an NSTextField containing some amount of text, and  
resize it
vertically so all the text fits within the frame? The sizeToFit  
message

seems to do this, except on the horizontal axis.


If you mean one line of text, there was [NSFont  
defaultLineHeightForFont] but that's depracated in 10.4 and you're  
supposed to use a layout manager (NSLayoutManager).


If you mean multiple lines of text, you must calculate it using a  
layout manager.  But I could never find a typesetter behavior which  
gave a reliably accurate answer for an NSTextField.  The closest is  
NSTypesetterBehavior_10_2_WithCompatibility.  It seems to me that  
Apple discourages multi-line NSTextFields.  (You can't make one in  
Interface Builder).  My advice: If it's more than one line, use  
NSTextView instead.  A few months ago I put together a demo which  
explains these issues.  You might want to run it, read the comments at  
the top of NS(Attributed)String+Geometrics.h, and/or check out the  
references.


http://sheepsystems.com/sourceCode/sourceStringGeometrics.html

Let me know if I made any conceptual errors in that thing.

___

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

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


EXC_BAD_ACCESS when calling CGContextDrawLayerInRect

2008-04-13 Thread Carter R. Harrison

Hi Everybody,

I'm delving into Quartz 2D programming for the first time so this is  
probably a newb issue, but either way I'm stumped.  I have a  
controller that is calling several custom drawing methods in my custom  
view.  The drawing methods call Quartz and tell it to draw various  
things to a CGLayer reference.  My drawRect: method of the custom view  
is responsible for taking the CGLayer and drawing it to the view.  To  
do this I'm using the CGContextDrawLayerInRect method of CGLayer:


CGContextRef context = [[NSGraphicsContext currentContext]  
graphicsPort];
CGContextDrawLayerInRect(context, CGRectMake([self frame].origin.x,  
[self frame].origin.y, [self frame].size.width, [self  
frame].size.height), cgback);


cgback is a instance variable pointing to a CGLayer.

So my code works, the correct things are being drawn to my view (more  
or less), but what happens is that after several seconds of use, the  
app crashes and I get an EXC_BAD_ACCESS error.  I know that this means  
somewhere a variable was freed and I'm still trying to access it, but  
the error is occurring within CGContextDrawLayerInRect and I have no  
way of knowing exactly what variable this is since I don't have the  
source.  I'm not explicitly freeing any of the variables that are  
being passed into CGContextDrawLayerInRect.  So I'm really at a loss.   
Has anybody experienced anything like this before?  Here is my stack  
trace.  Thanks everybody!


#0  0x08a0 in __memcpy
#1  0x924aacdf in CGAccessSessionGetBytes
#2  0x925141dc in partial_get_bytes
#3  0x92513f8f in CGAccessSessionGetChunks
#4  0x924b8759 in img_raw_read
#5  0x92471481 in img_data_lock
#6  0x9246f529 in CGSImageDataLock
#7  0x92b085ef in ripc_AcquireImage
#8  0x92af6d4f in ripc_DrawImage
#9  0x92890ce4 in dle_ExecuteDisplayList
#10 0x92892511 in dle_Execute
#11 0x92892a2d in CGDisplayListDelegateDrawDisplayList
#12 0x928932c6 in dlr_DrawLayer
#13 0x92515204 in CGContextDrawLayerInRect
#14 0x00036f89 in -[RDCView drawRect:] at RDCView.m:129



___

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

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

2008-04-13 Thread Jonathan Dann

In the mean time, there is this.

http://lipidity.com/apple/ilife-controls-hud-windows-and-more

Jon

On Sat, Apr 12, 2008 at 7:21 PM, Michael Watson <[EMAIL PROTECTED]>  
wrote:
You aren't missing anything. Apple gave us an official HUD panel and  
UI
guidelines surrounding it, and failed to provide any HUD-style  
controls to
go with it. If the idea is to give us something standard, so  
everyone's not

rolling slightly different HUD panels, we should have at least /some/
standard HUD controls.

Please, please file an enhancement request.


--
m-s


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]

Simple TextView not updating view

2008-04-13 Thread Johnny Lundy
First, thanks to Quincey Morris for clarifying the  
mutableArrayValueForKey issue to get proper KVO on a mutableArray when  
deleting objects from the Model. It works just fine. I think that will  
also allow me to get my addObject button to work.


I am tackling these issues one at a time. My goal here is just porting  
an existing AppleScript Studio app, which works fine, to use Cocoa  
Bindings, aiming for 100% "no-glue-code". Just to learn.


Next issue is that I have a simple NSTextView, plain text. It displays  
the current votes for each player suitable for copying and pasting  
into a forum thread post.


My app has one single class, VoterController: NSObject, which has all  
of the instance variables and instance methods. I should probably  
break it up, but for clarity it seems to help.


The Model is an NSMutableString

@property (readwrite, copy) NSMutableString *postText;
@synthesize postText;

The View is an NSTextView in IB, class left as the default NSTextView.  
Its bindings are:

Bind To: textViewController
Controller Key: selection
Model Key Path: postText

The Controller is textViewController, an NSObjectController. Its  
bindings are

Bind To: postText (an NSObject in IB that has class VoterController
Controller Key: blank
Model Key Path: postText (the Model Object, represented in IB by the  
above "postText" NSObject in IB)


The Model Object in IB is, as stated, an NSObject with class  
VoterController and name postText.


So the connections are

NSMutableString * postText instance variable ->postText NSObject in IB- 
>textViewController in IB ->NSTextView in IB.


Here is the method my code calls to modify the postText mutableString  
when there is a vote or an unvote. It summarizes all the votes for  
players in playerArray. threshold is a function that returns an integer.


- (NSMutableString *) postText
{
	postText = [NSMutableString stringWithFormat: @"Official Vote  
Count:\nNeeded To Lynch:%d\n", [self threshold]];

for (NSMutableDictionary *thePlayer in playerArray)
{
int currVote = [[thePlayer valueForKey:@"voteCount"]intValue];
if (currVote > 0)
{
		postText =  [[postText stringByAppendingFormat:@"%@ - %@ - %@ (L-%d) 
\n",

[thePlayer valueForKey:@"playerName"],
[thePlayer valueForKey:@"voteCount"],
[thePlayer 
valueForKey:@"votersForString"],
[self threshold] - currVote] 
mutableCopy];
}
}
[self saveToFile];
return postText;
}

The postText mutableString gets correctly modified, but does not  
change in the TextView.


I'm pretty sure I have the bindings wrong. Appreciate any help.

Cheers,

Johnny


___

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

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

2008-04-13 Thread Kevin Ross
I've been struggling for the past week with the exact same problem.   
Does anyone know of a workaround, or should I just roll my own PDFView  
and PDFThumbnailView?


Thanks for any ideas.

Kevin

On Apr 8, 2008, at 3:41 PM, Antonio Nunes wrote:


On Apr 8, 2008, at 10:19 PM, Justin Hawkwood wrote:

How do I call [myPDFView setDocument:previewPDF] without clearing  
out the undoManager?


I don't think you can. (And if you can, I'd really, really like to  
know :-) I filed a bug report on this  back in Feb. (#5733716).


António


Energy is like a muscle,
it grows stronger through being used.



___

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

Please do not post admin requests or moderator comments to the list.
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.beans%40sbcglobal.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: EXC_BAD_ACCESS when calling CGContextDrawLayerInRect

2008-04-13 Thread Quincey Morris


On Apr 13, 2008, at 07:15, Carter R. Harrison wrote:

CGContextDrawLayerInRect(context, CGRectMake([self frame].origin.x,  
[self frame].origin.y, [self frame].size.width, [self  
frame].size.height), cgback);


Are you sure you don't mean [self bounds]? The extent of a view in its  
drawing coordinate system is given by its bounds, not its frame.



___

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

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


Menu items vs modal sessions

2008-04-13 Thread Pierre Bernard

Hi!

How come some menu items are enabled and others disabled while there  
is a modal session going on?


Does this mean that Apple has implemented validateMenuItem somewhere  
in the responder chain to check for modalWindow and attachedSheet?

Where in the responder chain would that be?

I have wired up most of my menu items using Cocoa bindings. It would  
then only seem logical to use bindings to determine if those menu  
items should be enabled when a modal window or sheet is being  
displayed. So I bound enabled to NSApp.modalWindow and to  
window.attachedSheet using a NSIsNil transformer. Is the way to go?


Pierre

---
Pierre Bernard
http://www.bernard-web.com/pierre
http://www.houdah.com





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: HUD-style panel controls?

2008-04-13 Thread development2

Also check this out

http://shiira.jp/hmblkappkit/en.html


On Apr 13, 2008, at 9:02 AM, Jonathan Dann wrote:


In the mean time, there is this.

http://lipidity.com/apple/ilife-controls-hud-windows-and-more

Jon

On Sat, Apr 12, 2008 at 7:21 PM, Michael Watson [EMAIL PROTECTED]> wrote:
You aren't missing anything. Apple gave us an official HUD panel  
and UI
guidelines surrounding it, and failed to provide any HUD-style  
controls to
go with it. If the idea is to give us something standard, so  
everyone's not

rolling slightly different HUD panels, we should have at least /some/
standard HUD controls.

Please, please file an enhancement request.


--
m-s

___

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

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

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


Why should we set ivars to nil in dealloc?

2008-04-13 Thread Ferhat Ayaz
I see in some Apple's Cocoa examples that ivars are set to nil in the  
dealloc method.  The auto generated Core Data AppDelegate for new  
projects is doing this for each ivar. Here is a simple example:


- (void)dealloc {
[appointments release];
appointments = nil;
   [super dealloc];
}

why is it necessary to set the variable appointments (for instance) to  
nil in this example? Should we do this for each variable? When have we  
to do this?

Thanks,

Ferhat




___

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

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


Window moved when dock appears.

2008-04-13 Thread Mohsan Khan

Hi

I have a window (NSBorderlessWindowMask), this window gets pushed away  
when my Dock appears from being hidden.


How can I bypass this behaviour for my window?

Should I use applicationDidChangeScreenParameters and reposition the  
window, or is there an option to make my window not care about the  
Dock appearing?


Thanks, M
___

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

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


Some GC questions

2008-04-13 Thread Brendan Younger

Hello,

I've been writing a library that uses NSAllocateCollectable() quite a  
bit and I have a few questions about proper usage.


- Copying data
if I am copying to a malloc'd block, I can use memmove() regardless of  
whether the source is GC'd or not, right?
if I am copying to a GC block allocated with NSScannedOption, I need  
to use objc_memmove_collectable(), right?
if I am copying to a GC block allocated with nonscanned memory, I can  
use memmove(), right?


- Zero'ing data
There does not seem to be a GC-compatible bzero().  If I loop through  
and zero out each pointer in a scanned block, that would generate a  
write barrier for each pointer which is expensive.  However, if I use  
bzero(), then libauto won't know that I've messed with the block.   
Will it eventually figure it out when it does an exhaustive scan?  Or  
will it never notice that I've zero'd out the block?


Thanks,
Brendan
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why should we set ivars to nil in dealloc?

2008-04-13 Thread Jonathan del Strother
On Sun, Apr 13, 2008 at 6:48 PM, Ferhat Ayaz <[EMAIL PROTECTED]> wrote:
> I see in some Apple's Cocoa examples that ivars are set to nil in the
> dealloc method.  The auto generated Core Data AppDelegate for new projects
> is doing this for each ivar. Here is a simple example:
>
>  - (void)dealloc {
> [appointments release];
> appointments = nil;
>[super dealloc];
>  }
>
>  why is it necessary to set the variable appointments (for instance) to nil
> in this example? Should we do this for each variable? When have we to do
> this?

IMO, it's totally unnecessary.  Seems to be a cargo culting thing more
than anything else.
___

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

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

2008-04-13 Thread Michael Watson
What is your window for, exactly? Why don't you want it to respect the  
Dock? Most users get annoyed when windows don't respect the Dock area.



--
m-s

On 13 Apr, 2008, at 13:56, Mohsan Khan wrote:

Hi

I have a window (NSBorderlessWindowMask), this window gets pushed  
away when my Dock appears from being hidden.


How can I bypass this behaviour for my window?

Should I use applicationDidChangeScreenParameters and reposition the  
window, or is there an option to make my window not care about the  
Dock appearing?


Thanks, M
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/mikey-san 
%40bungie.org


This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSArray to NSString

2008-04-13 Thread Lincoln Green
I tried the following, which should work as far as I can see, and yet  
it doesn't.


	NSAttributedString *string = [textView attributedSubstringFromRange: 
[textView selectedRange]];

[textView setString:string];

Does anyone else see why it wouldn't work? When I perform my action,  
nothing happens.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why should we set ivars to nil in dealloc?

2008-04-13 Thread j o a r


On Apr 13, 2008, at 10:48 AM, Ferhat Ayaz wrote:
why is it necessary to set the variable appointments (for instance)  
to nil in this example? Should we do this for each variable? When  
have we to do this?



You should rarely, if ever, have to do this if your code is otherwise  
working correctly.


If you find that you need to set instance variables to nil in your  
dealloc method, this would in the general case point to problems  
_elsewhere_ in your code.


The reason would often be that you're doing "unsafe" things in your  
dealloc methods. Dealloc should in general be reserved to simply  
releasing your instance variables, and should not be overloaded with  
other functionality. Whenever you call out from your dealloc method  
(ie. any method you call on some other object than self, and even any  
method on self that you haven't implemented in your own class, or that  
could be overridden by subclasses) you invite problems.


Most of what I've said about dealloc also holds true for init methods  
btw.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: struct problem

2008-04-13 Thread Dean Ritchie

Earlier I wrote:


On Apr 13, 2008, at 5:31 AM, Thomas Backman wrote:

Are you running the app in debug mode? I've made the mistake of  
trying to debug in "release" mode a few times, and it often shows  
some insane values for variables.


This is news to me.  How can I tell?  In the Run menu, the Go item  
is Go(Debug).  What is this "release" mode and how can I avoid (or  
properly use) it?


Dean Ritchie


Well, I did find the place to change the mode, and when I change to  
debug mode, the struct values display correctly.  This closes the  
problem as far as I'm concerned:  Thanks to all for the helpful  
suggestions.


Dean Ritchie
___

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

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

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

This email sent to [EMAIL PROTECTED]


Subclassing NSScroller

2008-04-13 Thread Jonathan Dann

Hi All,

I'm trying to re-create the iTunes and HUD window scrollbars for my  
project.  I've managed to get a good looking NSScrollerKnob, and  
NSScrollerKnobSlot using bezier paths and gradients, but now I'm  
moving on to the arrows and the curved ends of the slot.


To get the knob I've overridden -drawKnob and the slot is done by  
overriding -drawKnobSlotInRect:highlight:.  By the same logic I  
thought that -drawArrow:highlight: would allow me to start playing  
with the arrows, but this never gets called.  Has anyone any  
experience with doing this, and changing the width of the whole  
(vertical) bar itself?  Passing arbitrary NSRects to -initWithFrame:  
doesn't seem to have any effect on the size of the scroll bar.


Thanks for your time,

Jon

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: NSArray to NSString

2008-04-13 Thread j o a r


On Apr 13, 2008, at 12:15 PM, Lincoln Green wrote:
	NSAttributedString *string = [textView attributedSubstringFromRange: 
[textView selectedRange]];

[textView setString:string];



You're passing an NSAttributedString to a method that expects a  
NSString.


You probably would want to have a look at the NSTextStorage property  
of your text view.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Menu items vs modal sessions

2008-04-13 Thread Keary Suska
on 4/13/08 10:12 AM, [EMAIL PROTECTED] purportedly said:

> How come some menu items are enabled and others disabled while there
> is a modal session going on?

Because the UI has to protect the integrity of the concept of modality. If
you bring up an application-modal window, you wouldn't want a user to be
able to ignore it, would you?
 
> Does this mean that Apple has implemented validateMenuItem somewhere
> in the responder chain to check for modalWindow and attachedSheet?
> Where in the responder chain would that be?

I am not sure precisely how AppKit does this, but I imagine that it simply
restricts event messages to just what the window can respond to (and maybe
more--don't recall now), depending on modality.

> I have wired up most of my menu items using Cocoa bindings. It would
> then only seem logical to use bindings to determine if those menu
> items should be enabled when a modal window or sheet is being
> displayed. So I bound enabled to NSApp.modalWindow and to
> window.attachedSheet using a NSIsNil transformer. Is the way to go?

If you already get certain behavior for free, why complexify it needlessly?
What problem are you trying to solve? If you have menu items that are
enabled during certain modal sessions, and you specifically don't want them
to, then you should look at your application design and adjust accordingly.
So, I guess to answer your questions, I would say, "probably not."

Better to follow the ways that AppKit wants you to do things (such as
intelligent use of the responder chain), rather than jerry-rig a band-aid
solution.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why should we set ivars to nil in dealloc?

2008-04-13 Thread Jerry Krinock


On 2008 Apr, 13, at 10:48, Ferhat Ayaz wrote:

I see in some Apple's Cocoa examples that ivars are set to nil in  
the dealloc method...why is it necessary...?


Usually it is not, but sometimes it is.  I can't remember the specific  
examples right now, but maybe to avoid a retain cycle, some other  
object may have a weak reference to the ivar, or the ivar may have  
been made a delegate of some object.  Messages to nil result in no-op  
but messages to deallocced objects result in a crash.


I suppose that if you always accessed ivars using their getter and  
never kept a reference around for later, you'd be safe, but maybe  
there are some circumstances when you don't want to do that.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Why should we set ivars to nil in dealloc?

2008-04-13 Thread stephen joseph butler
On Sun, Apr 13, 2008 at 12:48 PM, Ferhat Ayaz <[EMAIL PROTECTED]> wrote:

> why is it necessary to set the variable appointments (for instance) to nil
> in this example? Should we do this for each variable? When have we to do
> this?


Usually it's not. For me, it's 100% a "best practices" thing. It never
hurts, so why not get into the habit of doing it?
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Cocoa-dev Digest, Vol 5, Issue 600

2008-04-13 Thread Alex Curylo


On 13-Apr-08, at 12:02 PM, [EMAIL PROTECTED] wrote:
why is it necessary to set the variable appointments (for instance)  
to nil
in this example? Should we do this for each variable? When have we  
to do

this?


IMO, it's totally unnecessary.  Seems to be a cargo culting thing more
than anything else.



No, I can personally assure you that exact practice has led me to  
finding many dozens -- quite possibly several hundreds by now actually  
-- of 'calling methods of a deleted object' type bugs in C++ code,  
particularly game code I port from Windows, which somehow always seems  
to have been written by semi-literate chimpanzees on crack. And  
perhaps I am unfair to the chimpanzees here.


It does seem that class of problem is much less likely to arise with  
Objective-C object references (I'm still fairly new to this Cocoa  
thing) but as long as I still work with any C++ objects or raw  
pointers, I'm going to consider that "set things up so anything  
accessing this object's memory after I'm done with it promptly causes  
an access violation" is a valuable habit -- nay, essential practice --  
in properly defensive programming. Autoptrs and the like help, but  
they're not foolproof. Stands to reason that the retain/[auto]release  
paradigm isn't completely foolproof either, although it does seem  
pretty resistant to commonly accepted levels of foolery so far.


--
Alex Curylo -- [EMAIL PROTECTED] -- http://www.alexcurylo.com/

There are two great secrets to success in life.
The first is to not tell everything you know.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why should we set ivars to nil in dealloc?

2008-04-13 Thread j o a r


On Apr 13, 2008, at 12:27 PM, Jerry Krinock wrote:
Usually it is not, but sometimes it is.  I can't remember the  
specific examples right now, but maybe to avoid a retain cycle, some  
other object may have a weak reference to the ivar, or the ivar may  
have been made a delegate of some object.



This is not related to retain cycles at all.

In Non-GC, having a pointer to an object doesn't imply ownership. In  
GC it does (unless __weak), but the collector is smart enough to  
detect cycles.



Messages to nil result in no-op but messages to deallocced objects  
result in a crash.



...but if your code is designed in a way where messages are sent to  
deallocated objects, I would say that you should solve that problem,  
and not set your instance variables to nil. Fix it at the source.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Why should we set ivars to nil in dealloc?

2008-04-13 Thread Adam R. Maxwell


On Apr 13, 2008, at 12:14 PM, j o a r wrote:



On Apr 13, 2008, at 10:48 AM, Ferhat Ayaz wrote:
why is it necessary to set the variable appointments (for instance)  
to nil in this example? Should we do this for each variable? When  
have we to do this?



You should rarely, if ever, have to do this if your code is  
otherwise working correctly.


If you find that you need to set instance variables to nil in your  
dealloc method, this would in the general case point to problems  
_elsewhere_ in your code.


The reason would often be that you're doing "unsafe" things in your  
dealloc methods. Dealloc should in general be reserved to simply  
releasing your instance variables, and should not be overloaded with  
other functionality.


And if the OP is interested, Bill Bumgarner has some helpful posts on  
this in the archives.


Whenever you call out from your dealloc method (ie. any method you  
call on some other object than self, and even any method on self  
that you haven't implemented in your own class, or that could be  
overridden by subclasses) you invite problems.


As a concrete example, I ran into exactly this problem with an  
override of -[NSView discardCursorRects] (which had a radical  
documentation change from 10.4 to 10.5 and now sounds much less  
useful).  NSView's dealloc invokes -discardCursorRects, and my  
override was accessing an ivar that had already been deallocated.  At  
least that particular special case is now documented.


--
adam
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Re: EXC_BAD_ACCESS when calling CGContextDrawLayerInRect

2008-04-13 Thread Carter R. Harrison

On Apr 13, 2008, at 07:15, Carter R. Harrison wrote:


CGContextDrawLayerInRect(context, CGRectMake([self frame].origin.x,
[self frame].origin.y, [self frame].size.width, [self
frame].size.height), cgback);


Are you sure you don't mean [self bounds]? The extent of a view in its
drawing coordinate system is given by its bounds, not its frame


Yes, you are correct.  Thanks for the tip, but unfortunately this has  
not resolved the original issue.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Why should we set ivars to nil in dealloc?

2008-04-13 Thread j o a r


On Apr 13, 2008, at 12:36 PM, stephen joseph butler wrote:

Usually it's not. For me, it's 100% a "best practices" thing. It never
hurts, so why not get into the habit of doing it?



Two reasons:

* I don't think that it can be described as a best practice to begin  
with, and


* You could end up hiding what I would consider to be real problems in  
your code.


I want to detect real problems as soon as possible. Messaging  
deallocated objects, or objects that are in the process of being  
deallocated, is typically an error. The longer time you're unaware of  
something like this happening in your app, the more expensive it will  
be to fix it once it becomes a more serious problem.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSArray to NSString

2008-04-13 Thread Lincoln Green
Alright, the logic of this code(to me) is as follows; Make a new  
attributed string with the value of the textView's selected text.  
Then, print it in the console. But, of course, it doesn't work. what  
am I missing?


NSAttributedString *aString = [[textView textStorage]  
attributedSubstringFromRange:[textView selectedRange]];

NSLog([aString string]);

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why should we set ivars to nil in dealloc?

2008-04-13 Thread stephen joseph butler
On Sun, Apr 13, 2008 at 2:52 PM, j o a r <[EMAIL PROTECTED]> wrote:

> Two reasons:
>
> * I don't think that it can be described as a best practice to begin with,
> and
>
> * You could end up hiding what I would consider to be real problems in
> your code.
>
> I want to detect real problems as soon as possible. Messaging deallocated
> objects, or objects that are in the process of being deallocated, is
> typically an error. The longer time you're unaware of something like this
> happening in your app, the more expensive it will be to fix it once it
> becomes a more serious problem.


Well, in C/C++ accessing a NULL pointer will throw an error. But that type
of error is much safer than the alternates: double free or accessing a freed
region. Those aren't just programming problems, but security concerns.

Now, messaging nil in Obj-C is a pretty common thing; whether it's
intentional or not. But I think the security issues are still there with
double free or messaging a dealloced object.
___

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

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


IKImageBrowserView Title & Subtitle Woes

2008-04-13 Thread Thaddeus Cooper

Hello all.

I am trying to set the color of the title and subtitle in an  
IKImageBrowserView. From what I see in the documentation I need to set  
up a dictionary with key-value pairs that describe the attributes of  
what I want to set it to. I have the snippet of code that I'm trying  
to use below:


		NSDictionary *titleTextInfo = [NSDictionary dictionaryWithObject: 
[CIColor colorWithRed:0.0 green:1.0 blue:0.0] forKey:@"titleColor"];
		[myBrowserView setValue:titleTextInfo  
forKey:IKImageBrowserCellsTitleAttributesKey];


What I can't figure out is what is the magic key for setting the color  
of the title and subtitle. I've tried: foregroundColor,  
ForegroundColor, color, Color, titleColor, TitleColor and probably a  
few others. I've also tried using both CIColor (as shown above) and  
NSColor. As far as I can tell from a search of the documentation the  
actual keys are not documented.


Any help would be greatly appreciated.

Thanks very much.

Thaddeus O. Cooper
([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: Cocoa-dev Digest, Vol 5, Issue 600

2008-04-13 Thread Greg Titus


On Apr 13, 2008, at 12:40 PM, Alex Curylo wrote:
No, I can personally assure you that exact practice has led me to  
finding many dozens -- quite possibly several hundreds by now  
actually -- of 'calling methods of a deleted object' type bugs in C+ 
+ code, particularly game code I port from Windows, which somehow  
always seems to have been written by semi-literate chimpanzees on  
crack. And perhaps I am unfair to the chimpanzees here.


As a former game porter, let me offer my condolences here. I know  
exactly what you mean.


It does seem that class of problem is much less likely to arise with  
Objective-C object references (I'm still fairly new to this Cocoa  
thing) but as long as I still work with any C++ objects or raw  
pointers, I'm going to consider that "set things up so anything  
accessing this object's memory after I'm done with it promptly  
causes an access violation" is a valuable habit -- nay, essential  
practice -- in properly defensive programming. Autoptrs and the like  
help, but they're not foolproof. Stands to reason that the retain/ 
[auto]release paradigm isn't completely foolproof either, although  
it does seem pretty resistant to commonly accepted levels of foolery  
so far.


The big difference is that in Objective-C, trying to send a message to  
nil results in a no-op instead of an access violation, so your  
defensive C++ practice is actually going to tend to mask those same  
errors in Objective-C and make them harder to track down.


Hope this helps,
- Greg
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why should we set ivars to nil in dealloc?

2008-04-13 Thread Ferhat Ayaz


On Apr 13, 2008, at 9:41 PM, Adam R. Maxwell wrote:

Whenever you call out from your dealloc method (ie. any method you  
call on some other object than self, and even any method on self  
that you haven't implemented in your own class, or that could be  
overridden by subclasses) you invite problems.


As a concrete example, I ran into exactly this problem with an  
override of -[NSView discardCursorRects] (which had a radical  
documentation change from 10.4 to 10.5 and now sounds much less  
useful).  NSView's dealloc invokes -discardCursorRects, and my  
override was accessing an ivar that had already been deallocated.   
At least that particular special case is now documented.


This makes sense. However if I get into the habit of setting every  
ivar to nil without understanding the background why I have to do it,   
I will have the feeling that some foreign substances are swimming in  
my code.


Maybe it  is possible to invoke dealloc twice in multithreaded  
applications? And setting to nil prevents an exception like BAD_ACCESS  
if this happens?


Ferhat





___

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

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


Stale Objective-C object pointer detection

2008-04-13 Thread Alex Curylo


On 13-Apr-08, at 1:06 PM, Greg Titus wrote:
The big difference is that in Objective-C, trying to send a message  
to nil results in a no-op instead of an access violation, so your  
defensive C++ practice is actually going to tend to mask those same  
errors in Objective-C and make them harder to track down.


*smacks forehead*

Yeah, now that I actually think about it, that would be the effect,  
wouldn't it. Just hadn't made the connection up 'til now, somehow.  
Thank you.


OK, then, what would an equivalently useful value to set a released  
Objective-C object pointer/ivar to in order to cause any subsequent  
access of it to stop the program immediately? 0xDEADBEEF perhaps?


--
Alex Curylo -- [EMAIL PROTECTED] -- http://www.alexcurylo.com/

Programming is like sex...
One mistake and you support it the rest of your life.





___

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

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

2008-04-13 Thread Sean Todd
Thanks Mark (and Jim) for the NSZombieEnabled/NSDeallocateZombies  
reminder. This showed me that the object has indeed been deallocated  
by the time that breakpoint was reached.


Setting an earlier breakpoint I was able to get some more information  
on this unknown observer:


Options:  Context: 0x1e00b0, Property:  
0x1e1040>

)
(gdb) po 0x620c180
(
Options:  Context: 0x1e6450, Property:  
0x1e2ca0>

)

So this object is some array that contains single  
NSKeyValueObservance. Following the trail of observers shows:


(gdb) po 0x182180
category.color, Options:  Context: 0x0,  
Property: 0x62059d0>

(gdb) po 0x62005f0
{object: , bindings:  
content=arrangedObjects, selectionIndexes=selectionIndexes,  
sortDescriptors=sortDescriptors}


Unfortunately, I am still puzzled by how/why this array is set as an  
observer.


Setting a breakpoint with -addObserver:... (as suggested by Chuck  
Steinman) did not help as gdb could not provide any data via info args  
when this breakpoint was hit.


I am sure that this is due to changes in the KVO system in 10.5 but  
not sure if this is revealing a bug in that system or uncovering a  
problem with my use of KVO (perhaps some workaround code to a problem  
with KVO and bindings pre-10.5).



On Apr 12, 2008, at 7:42 PM, Mark Piccirelli wrote:

Yikes, that's not good. I'd try running with NSZombieEnable = YES to  
see if that turns up anything. That should also set  
NSDeallocateZombies = NO, which might make gdb po work.


-- Mark

On Apr 12, 2008, at 5:14 PM, Sean Todd wrote:

Unfortunately, that doesn't work:

grade, Options:  Context: 0x1957c0,  
Property: 0x18edf0>

)
(gdb) po 0x6500210

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0xc007391b
0xfffeff18 in objc_msgSend_rtp ()
The program being debugged was signaled while in a function called  
from GDB.

GDB has restored the context to what it was before the call.
To change this behavior use "set unwindonsignal off"
Evaluation of the expression containing the function  
(_NSPrintForDebugger) will be abandoned.



On Apr 12, 2008, at 5:18 PM, Mark Piccirelli wrote:
You can copy-and-paste to find out what the surprising observers  
are, as in:


(gdb) po 0x19e5a0

-- Mark

On Apr 12, 2008, at 2:59 PM, Sean Todd wrote:
I have a Cocoa document app that uses bindings. After installing  
10.5 and Xcode 3.0, I started seeing console output stating that  
objects were being deallocated while observers are still  
registered with them. After some investigation, I found that the  
objects being deallocated had an extra observer that I never  
registered (see the final observance instance listed in the - 
observationInfo output below:


(gdb) po [theItem observationInfo]
 (
name, Options:  Context: 0x0,  
Property: 0x19e5c0>
category, Options:  Context: 0x0,  
Property: 0x1a3c80>
grade, Options:  Context: 0x0,  
Property: 0x192920>
isDropped, Options:  Context: 0x0,  
Property: 0x1a3cd0>
grade, Options:  Context: 0x0,  
Property: 0x192920>
grade, Options:  Context: 0x18ea60,  
Property: 0x192920>

)

I have no idea what sort of object 0x6503f00 is or how/when it  
was registered. Looking at the address in memory did not give me  
any clues. The one interesting bit of info is that the address  
listed with its Context is the same as the first 4 observers.


Continuing on predictably leads to the console output:

2008-04-12 16:18:20.760 MyApp[329:813] An instance 0x1c3d40 of  
class Assignment is being deallocated while key value observers  
are still registered with it. Observation info is being leaked,  
and may even become mistakenly attached to some other object. Set  
a breakpoint on NSKVODeallocateBreak to stop here in the  
debugger. Here's the current observation info:

 (
grade, Options:  Context: 0x1c3ce0,  
Property: 0x192920>

)


When I debug this app with Xcode 2.4 on 10.4.x, there are no  
extra observers and everything works well.


I did not see anything addressing this issue in the foundation  
release notes. Nor have I found any discussion of this problem in  
the archives. Am I missing something? Do I need to file a bug?  
Any help would be appreciated.

___

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

Please do not post admin requests or moderator comments to the  
list.

Contact the moderators at cocoa-dev-admins(at)lists.apple.com

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

NSCompositeSourceOver equivalent in Quartz 2D?

2008-04-13 Thread Carter R. Harrison
I'm trying to do some drawing in Quartz 2D.  I'm trying to set the  
blending mode of my CGContextRef to the equivalent of  
NSCompositeSourceOver from NSGraphicsContext.  It doesn't look like  
there is such a blending mode for a CGContext.  Am I mistaken in this,  
or is there another way of accomplishing this?  It seems funny to me  
that this blending mode doesn't exist in Quartz given that  
NSGraphicsContext should be a wrapper class around CGContextRef.


Thanks in advance.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: IKImageBrowserView Title & Subtitle Woes

2008-04-13 Thread thomas goossens

Hi Thaddeus,

To change the title attributes,  use setValue:forKey with the key  
"IKImageBrowserCellsTitleAttributesKey" and pass a dictionary that  
contains the text attributes.
To get the list of keys for the attribute dictionary see the section  
"standard attributes" of the following page:


http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSAttributedString_AppKitAdditions/Reference/Reference.html

With attributes you can set the text alignment, line break mode, font,  
color...


NSMutableParagraphStyle *paragraphStyle = [[[NSMutableParagraphStyle  
alloc] init] autorelease];

[paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail];
[paragraphStyle setAlignment:NSCenterTextAlignment];

NSMutableDictionary attributes = [[NSMutableDictionary alloc]  
initWithCapacity:3];	


[attributes setObject:[NSFont fontWithName:@"Lucida Grande" size:12]  
forKey:NSFontAttributeName];
[attributes setObject:paragraphStyle  
forKey:NSParagraphStyleAttributeName];	
[attributes setObject:[NSColor colorWithDeviceRed:0 green:0 blue:0  
alpha:1] forKey:NSForegroundColorAttributeName];
[_imageBrowser setValue:attributes  
forKey:IKImageBrowserCellsTitleAttributesKey];

[attributes release];

If you just want to change the color and keep other settings unchanged  
you can do this: (I never tried it but that should work ;)


NSDictionary *oldAttributes = [_imageBrowser valueForKey:  
IKImageBrowserCellsTitleAttributesKey];

NSMutableDictionary *newAttributres = [oldAttributes mutableCopy];
[attributes setObject:[NSColor colorWithDeviceRed:1 green:0 blue:0  
alpha:1] forKey:NSForegroundColorAttributeName];
[_imageBrowser setValue: newAttributres  
forKey:IKImageBrowserCellsTitleAttributesKey];

[newAttributres release];

-- Thomas.

On Apr 13, 2008, at 10:01 PM, Thaddeus Cooper wrote:


Hello all.

I am trying to set the color of the title and subtitle in an  
IKImageBrowserView. From what I see in the documentation I need to  
set up a dictionary with key-value pairs that describe the  
attributes of what I want to set it to. I have the snippet of code  
that I'm trying to use below:


		NSDictionary *titleTextInfo = [NSDictionary dictionaryWithObject: 
[CIColor colorWithRed:0.0 green:1.0 blue:0.0] forKey:@"titleColor"];
		[myBrowserView setValue:titleTextInfo  
forKey:IKImageBrowserCellsTitleAttributesKey];


What I can't figure out is what is the magic key for setting the  
color of the title and subtitle. I've tried: foregroundColor,  
ForegroundColor, color, Color, titleColor, TitleColor and probably a  
few others. I've also tried using both CIColor (as shown above) and  
NSColor. As far as I can tell from a search of the documentation the  
actual keys are not documented.


Any help would be greatly appreciated.

Thanks very much.

Thaddeus O. Cooper
([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/tgoossens%40mac.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: struct problem

2008-04-13 Thread Michael Vannorsdel
This is because the actual value assignment was optimized and moved  
later in the code.  GDB can't really follow the source all that well  
because the instructions that belong to each line of code are now  
moved all around to improve performance.



On Apr 13, 2008, at 6:31 AM, Thomas Backman wrote:

Are you running the app in debug mode? I've made the mistake of  
trying to debug in "release" mode a few times, and it often shows  
some insane values for variables.


___

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

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

2008-04-13 Thread Thaddeus Cooper

Thanks very much Thomas -- it works now :-)

Thaddeus O. Cooper
([EMAIL PROTECTED])



On Apr 13, 2008, at 1:50 PM, thomas goossens wrote:

Hi Thaddeus,

To change the title attributes,  use setValue:forKey with the key  
"IKImageBrowserCellsTitleAttributesKey" and pass a dictionary that  
contains the text attributes.
To get the list of keys for the attribute dictionary see the section  
"standard attributes" of the following page:


http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSAttributedString_AppKitAdditions/Reference/Reference.html

With attributes you can set the text alignment, line break mode,  
font, color...


NSMutableParagraphStyle *paragraphStyle = [[[NSMutableParagraphStyle  
alloc] init] autorelease];

[paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail];
[paragraphStyle setAlignment:NSCenterTextAlignment];

NSMutableDictionary attributes = [[NSMutableDictionary alloc]  
initWithCapacity:3];	


[attributes setObject:[NSFont fontWithName:@"Lucida Grande" size:12]  
forKey:NSFontAttributeName];
[attributes setObject:paragraphStyle  
forKey:NSParagraphStyleAttributeName];	
[attributes setObject:[NSColor colorWithDeviceRed:0 green:0 blue:0  
alpha:1] forKey:NSForegroundColorAttributeName];
[_imageBrowser setValue:attributes  
forKey:IKImageBrowserCellsTitleAttributesKey];

[attributes release];

If you just want to change the color and keep other settings  
unchanged you can do this: (I never tried it but that should work ;)


NSDictionary *oldAttributes = [_imageBrowser valueForKey:  
IKImageBrowserCellsTitleAttributesKey];

NSMutableDictionary *newAttributres = [oldAttributes mutableCopy];
[attributes setObject:[NSColor colorWithDeviceRed:1 green:0 blue:0  
alpha:1] forKey:NSForegroundColorAttributeName];
[_imageBrowser setValue: newAttributres  
forKey:IKImageBrowserCellsTitleAttributesKey];

[newAttributres release];

-- Thomas.

On Apr 13, 2008, at 10:01 PM, Thaddeus Cooper wrote:

Hello all.

I am trying to set the color of the title and subtitle in an  
IKImageBrowserView. From what I see in the documentation I need to  
set up a dictionary with key-value pairs that describe the  
attributes of what I want to set it to. I have the snippet of code  
that I'm trying to use below:


		NSDictionary *titleTextInfo = [NSDictionary dictionaryWithObject: 
[CIColor colorWithRed:0.0 green:1.0 blue:0.0] forKey:@"titleColor"];
		[myBrowserView setValue:titleTextInfo  
forKey:IKImageBrowserCellsTitleAttributesKey];


What I can't figure out is what is the magic key for setting the  
color of the title and subtitle. I've tried: foregroundColor,  
ForegroundColor, color, Color, titleColor, TitleColor and probably  
a few others. I've also tried using both CIColor (as shown above)  
and NSColor. As far as I can tell from a search of the  
documentation the actual keys are not documented.


Any help would be greatly appreciated.

Thanks very much.

Thaddeus O. Cooper
([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/tgoossens%40mac.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: Stale Objective-C object pointer detection

2008-04-13 Thread Greg Titus
You want to just leave the pointer alone and turn on NSZombiesEnabled  
when you run your app. Then instead of the object on the other end of  
the pointer being freed, it'll point to a special zombie class which  
will helpfully raise you an exception when you try to send it a  
message. This has the added advantage of being able to more easily see  
what the pointer _used_ to point to, because the zombie has  
information about the original class name.


- Greg

On Apr 13, 2008, at 1:35 PM, Alex Curylo wrote:


On 13-Apr-08, at 1:06 PM, Greg Titus wrote:
The big difference is that in Objective-C, trying to send a message  
to nil results in a no-op instead of an access violation, so your  
defensive C++ practice is actually going to tend to mask those same  
errors in Objective-C and make them harder to track down.


*smacks forehead*

Yeah, now that I actually think about it, that would be the effect,  
wouldn't it. Just hadn't made the connection up 'til now, somehow.  
Thank you.


OK, then, what would an equivalently useful value to set a released  
Objective-C object pointer/ivar to in order to cause any subsequent  
access of it to stop the program immediately? 0xDEADBEEF perhaps?


--
Alex Curylo -- [EMAIL PROTECTED] -- http://www.alexcurylo.com/

Programming is like sex...
One mistake and you support it the rest of your life.






___

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

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


Mulitple Bindings and refreshing tables

2008-04-13 Thread antikraft clover
My first project using Bindings (my first project actually) and I am
having problems.
I have several tables that are bound to models. All these models are
related through a single column (sum of all items in column A of Table
1 gives the value of column A of Table 2 and so on). The bindings work
fine. But,when I edit the 'lowest' table's column A, I would like this
change to propogate to the 'higher' tables. Since, I am not
implementing the delegates of any table (all are connected via
bindings), the table reload their view only when I click on any one of
them.

Is there a "best way" of doing this?
Thanks
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Stale Objective-C object pointer detection

2008-04-13 Thread Alex Curylo


On 13-Apr-08, at 2:15 PM, Greg Titus wrote:
You want to just leave the pointer alone and turn on  
NSZombiesEnabled when you run your app.


Huh. I'd actually stumbled across NSDebug.h before, but the  
documentation at the top


"WARNING: Unsupported API.

This module contains material that is only partially supported -- if
at all.  Do not depend on the existance of any of these symbols in your
code in future releases of this software..."

sounded to to me an awful lot like "ignore this header". Righty then,  
now I know better. Thanks again!


--
Alex Curylo -- [EMAIL PROTECTED] -- http://www.alexcurylo.com/

You know you've had a good night when you wake up
and someone's outlining you in chalk.



___

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

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

2008-04-13 Thread Bill Bumgarner

On Apr 13, 2008, at 3:35 PM, Alex Curylo wrote:
OK, then, what would an equivalently useful value to set a released  
Objective-C object pointer/ivar to in order to cause any subsequent  
access of it to stop the program immediately? 0xDEADBEEF perhaps?


Well.. you could do what Greg said and go all NSZombie on it, but you  
have to remember to do that and stuff.


If you want a total hack, just assign (id) 0x1 to any variable that  
really ought to never be used again or better be initialized before  
being used again.


If you want to get terribly fancy, you could create your own root  
class that implements (on Leopard) -resolveInstanceMethod: /  
+resolveClassMethod: and logs, then crashes.


I wrote up some messaging hints here:

http://www.friday.com/bbum/2008/01/01/objective-c-a-hack-to-log-all-methods/
http://www.friday.com/bbum/2008/01/02/objective-c-logging-messages-to-nil/

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: NSArray to NSString

2008-04-13 Thread j o a r


On Apr 13, 2008, at 1:01 PM, Lincoln Green wrote:
Alright, the logic of this code(to me) is as follows; Make a new  
attributed string with the value of the textView's selected text.  
Then, print it in the console. But, of course, it doesn't work. what  
am I missing?


NSAttributedString *aString = [[textView textStorage]  
attributedSubstringFromRange:[textView selectedRange]];

NSLog([aString string]);



When you say "doesn't work", what does that mean?

Try something like this:

	NSLog(@"TV: %@, TS: %@, RNG: %@, ASTR: \"[EMAIL PROTECTED]", STR: \"[EMAIL PROTECTED]"",  
textView, [textView textStorage], NSStringFromRange([textView  
selectedRange]), aString, [aString string]);


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Why should we set ivars to nil in dealloc?

2008-04-13 Thread j o a r


On Apr 13, 2008, at 1:08 PM, Ferhat Ayaz wrote:
Maybe it  is possible to invoke dealloc twice in multithreaded  
applications? And setting to nil prevents an exception like  
BAD_ACCESS if this happens?



I'm not sure how you would end up in that type of situation (the  
default implementation of retain/release is thread safe), but lets for  
arguments sake say that you do - This would still indicate that you  
have a serious threading problem in your application, one that you  
should not attempt to hide by assigning nil to your ivars in dealloc.



On Apr 13, 2008, at 12:56 PM, stephen joseph butler wrote:
Well, in C/C++ accessing a NULL pointer will throw an error. But  
that type
of error is much safer than the alternates: double free or accessing  
a freed

region. Those aren't just programming problems, but security concerns.

Now, messaging nil in Obj-C is a pretty common thing; whether it's
intentional or not. But I think the security issues are still there  
with

double free or messaging a dealloced object.



If you want to protect yourself against that, while still allowing for  
clear and early detection of programmer errors, how about re-assigning  
the ivars to something that could never be an object address - Like 0x1.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Get "end-editing" notice from simple NSTextField?

2008-04-13 Thread Johnny Lundy
This list has been a great thing for me. I got 2 of my 3 stumpers  
solved with the help of people here.


What's the most clean and elegant (MVC compliant) way to receive an  
end-editing notice from a plain vanilla NSTextField?


I want my user to be able to just type in a string, end editing (by  
Return or Tab or changing focus), and then type in the next string,  
etc. and if my code can somehow get called I can add each entry to the  
array in the model.


I'd prefer not to use the Add: method of the array controllers unless  
it's the only clean way to do it, and of course avoid interacting with  
the NSTextField itself from the model.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why should we set ivars to nil in dealloc?

2008-04-13 Thread Clark Cox
On Sun, Apr 13, 2008 at 12:36 PM, stephen joseph butler
<[EMAIL PROTECTED]> wrote:
> On Sun, Apr 13, 2008 at 12:48 PM, Ferhat Ayaz <[EMAIL PROTECTED]> wrote:
>
>  > why is it necessary to set the variable appointments (for instance) to nil
>  > in this example? Should we do this for each variable? When have we to do
>  > this?
>
>
>  Usually it's not. For me, it's 100% a "best practices" thing. It never
>  hurts, so why not get into the habit of doing it?

Because it doesn't help either. I have never run into a situation
where setting an instance variable to nil in a -dealloc has provided
any benefit. At best, it does nothing, and at worst, it masks other
errors in your code.

The only way that it could ever affect your code is if you are
accessing an ivar of an already-dealloc'ed object; in which case
setting the ivar to nil only hides this problem.






-- 
Clark S. Cox III
[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: Subclassing NSScroller

2008-04-13 Thread slasktrattenator
I believe this is a typo in the documentation. The method you want to
override is actually spelled -drawArrow:highlightParts:

Hope this helps.

On Sun, Apr 13, 2008 at 9:18 PM, Jonathan Dann <[EMAIL PROTECTED]> wrote:
> Hi All,
>
>  I'm trying to re-create the iTunes and HUD window scrollbars for my
> project.  I've managed to get a good looking NSScrollerKnob, and
> NSScrollerKnobSlot using bezier paths and gradients, but now I'm moving on
> to the arrows and the curved ends of the slot.
>
>  To get the knob I've overridden -drawKnob and the slot is done by
> overriding -drawKnobSlotInRect:highlight:.  By the same logic I thought that
> -drawArrow:highlight: would allow me to start playing with the arrows, but
> this never gets called.  Has anyone any experience with doing this, and
> changing the width of the whole (vertical) bar itself?  Passing arbitrary
> NSRects to -initWithFrame: doesn't seem to have any effect on the size of
> the scroll bar.
>
>  Thanks for your time,
>
>  Jon
> ___
>
>  Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
>  Please do not post admin requests or moderator comments to the list.
>  Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
>  Help/Unsubscribe/Update your Subscription:
>
> http://lists.apple.com/mailman/options/cocoa-dev/slasktrattenator%40gmail.com
>
>  This email sent to [EMAIL PROTECTED]
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Mulitple Bindings and refreshing tables

2008-04-13 Thread Rob Keniger


On 14/04/2008, at 7:17 AM, antikraft clover wrote:

I have several tables that are bound to models. All these models are
related through a single column (sum of all items in column A of Table
1 gives the value of column A of Table 2 and so on). The bindings work
fine. But,when I edit the 'lowest' table's column A, I would like this
change to propogate to the 'higher' tables. Since, I am not
implementing the delegates of any table (all are connected via
bindings), the table reload their view only when I click on any one of
them.

Is there a "best way" of doing this?



It sounds like you are binding the tables directly to the model  
objects. While you can do this, it's not generally recommended. You  
will get much better results if you instead bind to one of the special  
bindings controllers such as NSArrayController, which is the "normal"  
method of using bindings.


I would highly recommend reading the Hillegass book as it describes  
how to use bindings correctly.


--
Rob Keniger



___

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

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

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

This email sent to [EMAIL PROTECTED]


A question about Tabviews and tabview items

2008-04-13 Thread Development
Is it possible to create a tabview who's tabviewitems have a custom  
look, For instance, the label is horizontal when the tabs are on the  
side, or can have icons? If so could I get a pointer to some info as I  
cant seem to find any.

___

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

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

2008-04-13 Thread Michael Ash
On Sun, Apr 13, 2008 at 5:33 PM, Alex Curylo <[EMAIL PROTECTED]> wrote:
>
>  On 13-Apr-08, at 2:15 PM, Greg Titus wrote:
>
> > You want to just leave the pointer alone and turn on NSZombiesEnabled when
> you run your app.
> >
>
>  Huh. I'd actually stumbled across NSDebug.h before, but the documentation
> at the top
>
>  "WARNING: Unsupported API.
>
>  This module contains material that is only partially supported -- if
>  at all.  Do not depend on the existance of any of these symbols in your
>  code in future releases of this software..."
>
>  sounded to to me an awful lot like "ignore this header". Righty then, now I
> know better. Thanks again!

Unsupported means that you can't rely on it, not that it doesn't work.
In other words, Apple doesn't wish to be committed to keeping this API
functional and changeless in all future releases of Mac OS X. You can
use it without any trouble on your own machine, but if you ship code
which uses anything from this header then you do so at your own risk.
Fortunately they're all things which you would generally only use on
your own machine, which is pretty much the point.

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: Subclassing NSScroller

2008-04-13 Thread Michael Watson

You should find this thread of interest:

http://www.cocoabuilder.com/archive/message/cocoa/2008/1/25/197293


--
m-s

On 13 Apr, 2008, at 15:18, Jonathan Dann wrote:

Hi All,

I'm trying to re-create the iTunes and HUD window scrollbars for my  
project.  I've managed to get a good looking NSScrollerKnob, and  
NSScrollerKnobSlot using bezier paths and gradients, but now I'm  
moving on to the arrows and the curved ends of the slot.


To get the knob I've overridden -drawKnob and the slot is done by  
overriding -drawKnobSlotInRect:highlight:.  By the same logic I  
thought that -drawArrow:highlight: would allow me to start playing  
with the arrows, but this never gets called.  Has anyone any  
experience with doing this, and changing the width of the whole  
(vertical) bar itself?  Passing arbitrary NSRects to -initWithFrame:  
doesn't seem to have any effect on the size of the scroll bar.


Thanks for your time,

Jon___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/mikey-san 
%40bungie.org


This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: KVO strangeness under 10.5

2008-04-13 Thread Mark Piccirelli

Sean --

Nothing in KVO's guts registers arrays as observers, and nothing in  
Cocoa Bindings either as far as I know.


For the curious, NSKeyValueObservances are instances of an internal  
class that gets instantiated and put in the observation info of  
observed object. (Hugely subject to change; no one should write apps  
that depend on these details.) In 10.5 they are also used as observers  
when key paths are being observed. For example, the observance for an  
object's "category.color" is itself an observer of the "color" of the  
object's current "category" and forwards notifications to the ultimate  
observer. When the object's "category" changes it also removes itself  
as an observer the old value's "color" and adds itself as an observer  
of the new value before sending the notification to the ultimate  
observer. So, it makes sense that you're seeing NSKeyValueObservances  
as observers.


One possible cause of what you're seeing might be bad KVO-compliance  
for "category." If KVO itself doesn't get notified of changes to that  
value the machinery just described gets pretty confused. There are  
exceptions thrown for many instances of that mistake but perhaps not  
all.


Anyway, an app that works on 10.4 but not on 10.5 always smells like a  
backward binary incompatibility in our stuff regardless of where the  
actual programming mistake is. Please file a bug report with  
instructions on how to reproduce this problem. Hopefully your app is  
something you can attach or point us to. Thanks…


-- Mark

On Apr 13, 2008, at 1:35 PM, Sean Todd wrote:

Thanks Mark (and Jim) for the NSZombieEnabled/NSDeallocateZombies  
reminder. This showed me that the object has indeed been deallocated  
by the time that breakpoint was reached.


Setting an earlier breakpoint I was able to get some more  
information on this unknown observer:


grade, Options:  Context: 0x1e00b0,  
Property: 0x1e1040>

)
(gdb) po 0x620c180
(
Options:  Context: 0x1e6450, Property:  
0x1e2ca0>

)

So this object is some array that contains single  
NSKeyValueObservance. Following the trail of observers shows:


(gdb) po 0x182180
category.color, Options:  Context: 0x0,  
Property: 0x62059d0>

(gdb) po 0x62005f0
{object: ,  
bindings: content=arrangedObjects,  
selectionIndexes=selectionIndexes, sortDescriptors=sortDescriptors}


Unfortunately, I am still puzzled by how/why this array is set as an  
observer.


Setting a breakpoint with -addObserver:... (as suggested by Chuck  
Steinman) did not help as gdb could not provide any data via info  
args when this breakpoint was hit.


I am sure that this is due to changes in the KVO system in 10.5 but  
not sure if this is revealing a bug in that system or uncovering a  
problem with my use of KVO (perhaps some workaround code to a  
problem with KVO and bindings pre-10.5).



On Apr 12, 2008, at 7:42 PM, Mark Piccirelli wrote:
Yikes, that's not good. I'd try running with NSZombieEnable = YES  
to see if that turns up anything. That should also set  
NSDeallocateZombies = NO, which might make gdb po work.


-- Mark

On Apr 12, 2008, at 5:14 PM, Sean Todd wrote:

Unfortunately, that doesn't work:

grade, Options:  Context: 0x1957c0,  
Property: 0x18edf0>

)
(gdb) po 0x6500210

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0xc007391b
0xfffeff18 in objc_msgSend_rtp ()
The program being debugged was signaled while in a function called  
from GDB.

GDB has restored the context to what it was before the call.
To change this behavior use "set unwindonsignal off"
Evaluation of the expression containing the function  
(_NSPrintForDebugger) will be abandoned.



On Apr 12, 2008, at 5:18 PM, Mark Piccirelli wrote:
You can copy-and-paste to find out what the surprising observers  
are, as in:


(gdb) po 0x19e5a0

-- Mark

On Apr 12, 2008, at 2:59 PM, Sean Todd wrote:
I have a Cocoa document app that uses bindings. After installing  
10.5 and Xcode 3.0, I started seeing console output stating that  
objects were being deallocated while observers are still  
registered with them. After some investigation, I found that the  
objects being deallocated had an extra observer that I never  
registered (see the final observance instance listed in the - 
observationInfo output below:


(gdb) po [theItem observationInfo]
 (
name, Options:  Context: 0x0,  
Property: 0x19e5c0>
category, Options:  Context: 0x0,  
Property: 0x1a3c80>
grade, Options:  Context: 0x0,  
Property: 0x192920>
isDropped, Options:  Context: 0x0,  
Property: 0x1a3cd0>
grade, Options:  Context: 0x0,  
Property: 0x192920>
grade, Options:  Context: 0x18ea60,  
Property: 0x192920>

)

I have no idea what sort of object 0x6503f00 is or how/when it  
was registered. Looking at the address in memory did not give me  
any clues. The one interesting bit of info is that the address  
listed 

re: Core Data for managing subtree?

2008-04-13 Thread Ben Trumbull

At 6:13 PM -0700 4/8/08, [EMAIL PROTECTED] wrote:

However, I would like to use Core Data to manage these items. I figure
I could have my add and remove methods insert and remove objects from
the managed object context as well as the KVO-compliant mutable array,
but when I undo such an action, the change will only be reflected in
the managed object context. I could create an extra entity to act as a
collection for those items and have the add and remove methods
manipulate that object, but I don't see how this collection could then
be KVO-related to its parent node as per mutableArrayValueForKey:.


Hamish,

The easiest way to get array and tree controllers to work with Core 
Data results is to put them into Entity mode.  If you want to bind to 
a to-many relationship keypath, you can bind to their 'contentSet'. 
Core Data to-many relationships respond to mutableSetValueForKey:


If you only want only some of the tree using Core Data objects, you 
could try having an array controller manage the extra entity, and 
wire its content into your tree controller.  You don't need a to-many 
relationship for that.  The array controller in entity mode directly 
observes the NSManagedObjectContext with which it is associated.


If you want to customize things even further, you can observe the 
NSManagedObjectContext's 
NSManagedObjectContextObjectsDidChangeNotification yourself, and 
update your custom controllers based on the contents of that 
NSNotification.  The array controller in entity mode is basically 
doing this, plus observing some of the managed object properties 
directly with KVO.


--

-Ben
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Basic Core Animation question

2008-04-13 Thread Scott Anguish
delegate, subclass or setting the contents property (not applicable in  
this case)..


all are valid ways to provide the data..


On Apr 13, 2008, at 3:01 AM, Greg Sabo wrote:
Now to get the CALayer to draw a path. Most of the documentation  
I've seen
suggest to do this with a delegate function, is that correct? Here  
is the

delegate function I've written (a.k.a. copied from another program):


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why should we set ivars to nil in dealloc?

2008-04-13 Thread Ben Trumbull

Seriously, we're arguing about this ?


If you want a total hack, just assign (id) 0x1 to any variable that


... please step away from the tequila.

I have a radical suggestion:

Test your software.

Like crazy talk!!

The detection of this class of bugs is extraordinarily easy to 
automate, so my sympathy is lower than its usual nonexistence.


Here are the environment variables to set:

export NSZombieEnabled=YES
export CFZombieLevel=9
export MallocScribble=1
export MallocPreScribble=1
export MallocGuardEdges=1

You don't have to remember to run with these flags.  Because, of 
course, you have unit tests to at least provide some basic code 
coverage.


If you don't, you really need to stop and fix that first.  I can't 
say I enjoy it, but begrudgingly, the results and ROI from unit tests 
have been extremely impressive.  Compared to the previous project I 
worked on (no unit tests), we've been able to make much more 
aggressive changes, and innovate faster, on my current project 
entirely due to the unit testing infrastructure.


And then, you find an old mac mini or imac, and set up a cronjob to 
run your unit tests every night.  Once you have nightly unit tests 
set up, running them again with different env flags is effortless.


If you're wondering wtf CFZombieLevel 9 does, check out Most Awesome 
TechNote Ever:



Also, for more paranoia (at 100x slower), you can use (do NOT mix 
with the above):


export DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib
export MALLOC_FILL_SPACE=1

Since those two modes behave differently, we run both nightly.

And while we're on this subject, there's another class of bugs that 
nightly testing can really help with: leaks.


There are two easy leak tools to use via scripts.  'leaks' and 
'heap'.  Leaks is a good first pass, which rarely has false 
positives, but very often has false negatives.  Nevertheless, if your 
code can't pass through leaks, you have a pretty big problem.  So 
'heap' fills in the gap to catch the leaks that 'leaks' missed.


To use 'heap' to catch leaks, you'll want to create a black list. 
For example, in Core Data, after each unit test, we grep through the 
heap result to see if there are any NSManaged*, NSEntity*, etc etc. 
We skip over stuff that's hard to sort through, like NSString, but we 
can at least ensure that none of our classes are still present in the 
heap.  That's a pretty thorough leak detection.


This is a bit harder than zombies, because you'll need to white list 
known problems (in other people's code), and for the heap tool create 
a custom black list.  But this is absolutely worth the effort.


Running unit tests through debugging tools (zombies, leaks, etc) 
nightly has been the single highest return on effort debugging 
decisions I've ever seen.


Ever.  Seen.

The second highest was actually writing the unit tests in the first 
place, a necessary prerequisite, but more effort.


Just imagine what you could do mixing this stuff with dtrace ...
--

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


showing a list of objects

2008-04-13 Thread Torsten Curdt

Hey guys,

I have been asking a few questions around NSCollectionView and  
NSTableView before. While I did get some of it working just fine, I've  
also run into one or the other problem. So I thought I take a step  
back and ask for some more general feedback. So I thought I just  
explain what I want to implement and I hope I get pointed into the  
right direction.


So in core data I have a list of objects. The model is roughly like  
this:


Action {
  NSString *Text;
  NSDate *Date;
  NSString *Other;
}

This model is bound to a NSArrayController. Now I want to create an UI  
to show and edit a set of these objects. A NSTableView or  
NSCollectionView come to mind. But the object visualization has some  
constraints. The length of the "Text" attribute can be quite  
different. Which means the visualization of some of the "Action"  
objects requires a different height of the rows. Essentially the  
NSTextField should resize accordingly. Also the normal table column  
view of the attributes is not really good enough for this application.  
It should be more like a custom view.


Now IIUC having different heights is a problem at least for a  
NSCollectionView. Would that be possible with a NSTableView by writing  
my own NSTableCell? Or would it be better to go for a custom view  
(NSScrollView?) that I'll connect to the NSArrayController that knows  
how to draw the "Action" objects?


How would you guys tackle something like that? I couldn't really think  
of any open source project (or example) to look at how it's done.

Any pointers?

cheers
--
Torsten
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Subclassing NSScroller

2008-04-13 Thread Chris Hanson

On Apr 13, 2008, at 3:13 PM, [EMAIL PROTECTED] wrote:


I believe this is a typo in the documentation. The method you want to
override is actually spelled -drawArrow:highlightParts:


In , Troy Stephens responds to Michael Watson's mention  
of that method with:



That method isn't part of NSScroller's published API (note its absence
from NSScroller.h).  Therefore it's subject to disappearing without
warning in a future release, and you should avoid any reliance on it
in your code.


Don't rely on anything that isn't API.  If there's something you can't  
do within the API, please file a bug at   
and describe what you're trying to create.


  -- Chris

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Get "end-editing" notice from simple NSTextField?

2008-04-13 Thread Ben Lachman

On Apr 13, 2008, at 5:57 PM, Johnny Lundy wrote:

This list has been a great thing for me. I got 2 of my 3 stumpers  
solved with the help of people here.


What's the most clean and elegant (MVC compliant) way to receive an  
end-editing notice from a plain vanilla NSTextField?


I want my user to be able to just type in a string, end editing (by  
Return or Tab or changing focus), and then type in the next string,  
etc. and if my code can somehow get called I can add each entry to  
the array in the model.


If you hook up the textfield's delegate it will receive  
controlTextDidEndEditing: if you've implemented it.  This goes for  
all controls actually (not all controls actually produce these  
messages of course).


->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

[EMAIL PROTECTED]
740.590.0009

___

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

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

2008-04-13 Thread Dan Knapp
Hi, all!  I'm posting this question here because this list keeps coming up
when I search for information on things I'm working on, so I figure if
anyone can figure this out, it'll be here.
I'm trying to add an NSRuleEditor-like interface to my app, but I'm rolling
my own because I gave up on figuring out the official one. :)  It's not that
big a task, anyway, so I'm fine with that...

I have Core Data entities Condition (abstract), CompoundCondition, and
KnowledgeCondition, each with their own custom classes.  Weirdly, I get an
error only when attempting to add a third child to an existing item - I can
delete and add children one and two as much as I want without triggering the
problem, and if I (somehow - I can't reproduce it) get past that, I can
continue to delete and add then as well.  It's only at the transition from
two to three that's the problem.

Anyway, the error looks like:

*2008-04-13 22:27:25.180 Dialogue[56287:10b] *** -[NSCFArray member:]:
unrecognized selector sent to instance 0x10e65f0*

*2008-04-13 22:27:25.181 Dialogue[56287:10b] *** -[NSCFArray member:]:
unrecognized selector sent to instance 0x10e65f0*

Well, yeah - it can't find the selector because it's not a set, it's an
array.  But this is baffling, because I requested it with
mutableSetValueForKey!  Doing po on the address gives me:

(

 (entity: KnowledgeCondition; id: 0x10ff2a0
 ;
data: {

character = nil;

index = 0;

knowledge = nil;

mode = 1;

parent = 0x10cf080
;

trigger = nil;

}),

 (entity: KnowledgeCondition; id: 0x10df1c0
 ;
data: {

character = nil;

index = 5;

knowledge = nil;

mode = 1;

parent = 0x10cf080
;

trigger = nil;

})

)

Which, indeed, looks like a valid representation of my data - except for
some reason as an array rather than a set.

Does anybody have any idea how I can debug this?

By the way, this problem is similar to one described a couple years ago, but
there was no resolution in that thread.  I'm hoping that means it was
something simple and silly!
http://www.cocoabuilder.com/archive/message/cocoa/2006/1/20/154873

-- 
Dan Knapp
"An infallible method of conciliating a tiger is to allow oneself to be
devoured." (Konrad Adenauer)
___

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

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


NSMatrix Content Binding

2008-04-13 Thread Seth Willits

Howdy,


I have a matrix of radio buttons that I'm trying to bind-ify. The two  
options in the matrix should shown with the titles:


Mac OS Extended
Mac OS Extended Journaled

The *values* of these two items should be:

HFS+
Journaled HFS+

Then what I'd like to do is bind the selectedValue of the matrix  
(which would be either "HFS+" or "Journaled HFS+") to a string  
property in my model.




I can bind the content of the matrix to my model's "diskImageFormats"  
key path which would be:


- (NSArray *)diskImageFormats;
{
	return [NSArray arrayWithObjects:@"Mac OS Extended", @"Mac OS  
Extended (Journaled)", nil];

}


...and that properly sets the titles of the two buttons, but the  
values are still the titles. So I *thought* could simply bind  
contentValues to another key path such as:


- (NSArray *)diskImageFormatValues;
{
return [NSArray arrayWithObjects:@"HFS+", @"Journaled HFS+", nil];
}

...but this doesn't work, because apparently the key path of  
contentValues must have the content key path as a prefix, such as  
"diskImageFormat.value" which entails a certain organization that  
seems to be too far off from what I need.




Is there a way to do what I want to do?



--
Seth Willits




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Window moved when dock appears.

2008-04-13 Thread Seth Willits

On Apr 13, 2008, at 10:56 AM, Mohsan Khan wrote:

I have a window (NSBorderlessWindowMask), this window gets pushed  
away when my Dock appears from being hidden.


Huh. I wouldn't expect it to do that given that it's borderless.




How can I bypass this behaviour for my window?

Should I use applicationDidChangeScreenParameters and reposition the  
window, or is there an option to make my window not care about the  
Dock appearing?


It'd probably be easier to just override setFrame in a window subclass  
and make sure it's always what it should be. Just a thought.




--
Seth Willits




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data -- "[NSCFArray member:]: unrecognized selector" -- solved my own problem

2008-04-13 Thread Dan Knapp
Naturally, right after I gave up on solving it for the night, I guessed the
solution.
I figured I'd reply to myself and say that, to save others the trouble of
trying.
It was indeed something embarrassingly simple: I had accidentally created a
method with the same name as an accessor which otherwise would have been
autogenerated, overriding it.  Changing the name of that method made it all
work.

Oh well - thanks to anyone who took the time to read this!

-- 
Dan Knapp
"An infallible method of conciliating a tiger is to allow oneself to be
devoured." (Konrad Adenauer)
___

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

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


Running a "Choose Template" Sheet

2008-04-13 Thread Kip Nicol

Hello everyone,

I'm trying to implement a "Choose Template" sheet that pops down with  
the creation of a new document, one very similar to the "Choose  
Template" sheet that pops down for each new Keynote document.


I've researched it a bit and found an app that subclasses  
NSDocumentController and overrides  
openUntitledDocumentAndDisplay:error: method and runs the sheet there.  
Is this the correct place to be running the sheet? Thanks!


Kip Nicol
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why should we set ivars to nil in dealloc?

2008-04-13 Thread Bill Bumgarner

On Apr 13, 2008, at 6:35 PM, Ben Trumbull wrote:

Seriously, we're arguing about this ?


If you want a total hack, just assign (id) 0x1 to any variable that


... please step away from the tequila.


Heh.  No amount of testing (see below for framing of this statement)  
will catch every fault.I like my software to fail catastrophically  
throughout the beta period (or pre-submission period, in many cases)  
if anything I didn't catch in testing falls through the cracks.   Nor  
can you expect to have all the full-on testing goop enabled outside of  
your development environment.


For example, how long does the typical app run for with libgmalloc  
hanging out and chewing up pages?



Running unit tests through debugging tools (zombies, leaks, etc)  
nightly has been the single highest return on effort debugging  
decisions I've ever seen.


Ever.  Seen.

The second highest was actually writing the unit tests in the first  
place, a necessary prerequisite, but more effort.


Just imagine what you could do mixing this stuff with dtrace ...


But, really, what Ben said.  Seriously.   Unit tests, automated tests,  
and doing them continuously goes a really really long way to  
minimizing defect analysis pain.


Applying the system provided analysis tools during testing runs is  
relatively easy and extremely useful, too. The tools are there, might  
as well use 'em.


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: A question about Tabviews and tabview items

2008-04-13 Thread Sean Murphy

On Apr 13, 2008, at 6:24 PM, Development wrote:

Is it possible to create a tabview who's tabviewitems have a custom  
look, For instance, the label is horizontal when the tabs are on the  
side, or can have icons? If so could I get a pointer to some info as  
I cant seem to find any.


Rather than subclassing NSTabView (since it does not really expose any  
mechanism to override tab drawing), custom tabs can be implemented by  
hiding the NSTabView's tab buttons and utilizing a completely separate  
custom "tab bar" view containing your buttons.  The custom view would  
then oversee the actual NSTabView's selection, set as its delegate to  
monitor outside selection changes, and would itself switch to the  
proper NSTabViewItems when clicked.


For some examples of this approach, take a look at what we do in  
Camino: 


And see the excellent PSMTabBarControl:



-Murph
___

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

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

2008-04-13 Thread Sean Murphy


On Apr 13, 2008, at 11:10 PM, Kip Nicol wrote:

I'm trying to implement a "Choose Template" sheet that pops down  
with the creation of a new document, one very similar to the "Choose  
Template" sheet that pops down for each new Keynote document.


Kip,

Erik Buck wrote an article about such an implementation over at  
stepwise:
.  Looking at it  
quickly, he performs the "show template sheet" method in - 
windowControllerDidLoadNib:.


Hope that helps,
-Murph
___

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

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

2008-04-13 Thread Steve Sheets
Has anyone had any problems with creating Properties with Objective-C  
2.0 that are also Outlets?


I been using this inside my code, and I want to be sure there is no  
problems with this. I create fairly standard (readonly) and  
(readwrite, copy) properties using ivars, @property and @synthesize. I  
place IBOutlet in front of the ivar like thus:




IBOutlet NSView* myView;
IBOutlet NSWindow* myWindow;

...

@property (readwrite, retain) NSView* myView;
@property (readonly) NSWindow* myWindow;

...

@synthesize myView;
@synthesize myWindow;

Sometimes the view or window are used as Outlets by the nib file, and  
other times the code creates them on the fly.


The documentation does not explicitly say you can do this. I just want  
to know if anyone has seen an issue?


Thanks,

Steve Sheets
___

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

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

2008-04-13 Thread Seth Willits

On Apr 13, 2008, at 9:46 PM, Steve Sheets wrote:

The documentation does not explicitly say you can do this. I just  
want to know if anyone has seen an issue?


I would fully expect it work just fine. Not an authoritative answer,  
but it must be reassuring to know I don't think you're crazy. :)



--
Seth Willits




___

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

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

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

This email sent to [EMAIL PROTECTED]


NSDateFormatter giving different results in different programs

2008-04-13 Thread Derrick Bass
I have a framework with a method that uses NSDateFormatter to convert  
an NSString to an NSDate:
	NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init]  
autorelease];

NSDate *date = [dateFormatter dateFromString:creationDateString];

creationDateString is set to @"Sun Mar 18 22:17:02 2007"

In one program that links to this framework, the date is getting  
parsed correctly. But in another, the very same string is coming back  
as "1969-12-31 16:00:00 -0800"! Using - 
[getObjectValue:forString:range:error:] gives the same results no  
error.


What could be causing the different behaviors and how do I get the  
string to parse no matter what?


Thanks!

Derrick

___

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

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


Plugin Information

2008-04-13 Thread Rick Langschultz

Hello everyone,

My application uses plugins from a support folder in /Library/ 
Application Support/AppName/Plugins/. The application searches this  
folder for all the plugins and loads them. But here is my dilemma: i  
want to put the plugin class name as the bundle identifier so that i  
can call methods from those classes when something in the main  
application is triggered.


For instance, I have a plugin called A.plugin, B.plugin, and C.plugin  
with Principal Classes named APluginClass, BPluginClass, and  
CPluginClass respectively. They conform to AppNameProtocol which has  
an installation, allocation/init, dealloc, and other class names.


My code uses NSString *bundlePath, and NSBundle *bundle. I want to  
have something like *bundlePathA, *bundlePathB, etc; and *bundleA,  
*bundleB, *bundleC. Is there a simple way that I can do this?


I have researched NSBundle on the Developer docs, and on apple.com,  
along with some code on google.com/codesearch .


Can anyone give me a pointer or two?

Thanks,

Rick L.
___

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

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