Re: Calling Methods From Custom UIImageView's initWithImage

2009-12-04 Thread Chunk 1978
thanks.   :)



On Sat, Dec 5, 2009 at 1:56 AM, Graham Cox  wrote:
>
> On 05/12/2009, at 5:47 PM, Chunk 1978 wrote:
>
>
>
>> –
>> #import 
>>
>> @interface myUIImageViewClass : UIImageView
>
>
>>       imageViewClass = [[UIImageView alloc] initWithImage:myImage];
>
>
> That should be:
>
>  imageViewClass = [[myUIImageViewClass alloc] initWithImage:myImage];
>
> You defined a subclass but you're not allocating an object of that class.
>
> --Graham
>
>
>
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Calling Methods From Custom UIImageView's initWithImage

2009-12-04 Thread Graham Cox

On 05/12/2009, at 5:47 PM, Chunk 1978 wrote:



> –
> #import 
> 
> @interface myUIImageViewClass : UIImageView


>   imageViewClass = [[UIImageView alloc] initWithImage:myImage];


That should be:

 imageViewClass = [[myUIImageViewClass alloc] initWithImage:myImage];

You defined a subclass but you're not allocating an object of that class.

--Graham


___

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

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

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

This email sent to arch...@mail-archive.com


Calling Methods From Custom UIImageView's initWithImage

2009-12-04 Thread Chunk 1978
i'm trying to understand how to create my own UIImageView class with
it's own custom methods that are fired from the initWithImage method,
but i can't get it to work.  i believe i'm missing something
fundemental, which for some reason hasn't yet clicked in my head, so
please help me understand what i'm doing wrong.

this is my UIImageViewController .h and .m:

–
#import 
@class myUIImageViewClass;


@interface myViewController : UIViewController
{
myUIImageViewClass *imageViewClass;
}

@property (nonatomic, retain) myUIImageViewClass *imageViewClass;;

@end
–
–
#import "myViewController.h"
#import "myUIImageViewClass.h"

@implementation myViewController
@synthesize imageViewClass;


- (void)viewWillAppear:(BOOL)animated
{
UIImage *myImage = [UIImage imageNamed:@"myImage.png"];
imageViewClass = [[UIImageView alloc] initWithImage:myImage];
[imageViewClass setFrame:CGRectMake(0, 0, myImage.size.width,
myImage.size.height)];

[self.view addSubview:imageViewClass];
[imageViewClass release];

[super viewWillAppear:animated];
}

- (void)dealloc
{
[imageViewClass release];
[super dealloc];
}

@end
–


now my custom UIImageView class does get added as a subview, but the
methods that are suppose to fire from the initWithImage class do not
get called.  here are the .h and .m for myUIImageViewClass


–
#import 

@interface myUIImageViewClass : UIImageView
{
}

- (void)logImageSize:(UIImage *)image;

@end
–
–
#import "myUIImageViewClass.h"

@implementation myUIImageViewClass

- (id)initWithImage:(UIImage *)image
{
if (self = [super initWithImage:image])
[self logImageSize:image];

return self;
}

- (void)logImageSize:(UIImage *)image
{
NSLog(@"Width:%.0f – Height:%.0f", image.size.width, image.size.height);
}

@end
–
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Getting Text Colors Right for Derived NSTextFieldCell under Various Conditions

2009-12-04 Thread Jim Correia
On Dec 4, 2009, at 10:54 PM, Grant Erickson wrote:

> Thanks for the prompt reply. I forgot to mention one key element. The
> subclass must support 10.4- and later so I cannot rely on 10.5- and later
> APIs such as this.

In that situation I’d probably write (and test!) 

if ([self respondsToSelector: @selector(interiorBackgroundStyle)]) {
… compute text color from background style ...
} else {
… best effort text color calculation ...
}

Hopefully sometime soon the 10.4 branch can just go away.

(If you have an existing product which already targets 10.4, changing the 
system requirements for something like this seems drastic. However, if you are 
developing a new product, you may want to seriously consider whether you really 
need to support Tiger, and the opportunity cost of doing so.)

Jim___

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

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

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

This email sent to arch...@mail-archive.com


Re: Is it possible to pass an object to a NIB

2009-12-04 Thread Chris Hanson
On Dec 4, 2009, at 7:47 PM, DeNigris Sean wrote:

> I'm writing a RubyCocoa app, but my question is on the Cocoa API...
> 
> I'm trying to unit test a view class.  As it is very thin (just delegates all 
> work to the controller), all I want to check is that my connections (e.g. 
> outlets and actions) are hooked up correctly.
> 
> I've been trying to:
> 1. Create an instance of my class
> 2. use NSBundle::loadNibFile: externalNameTable: withZone: to load the nib
> 3. check the connections

Really, the external name table is for referring to objects in nibs, rather 
than pushing objects into nibs.

Furthermore, from your further description it sounds like what you’re referring 
to as a “view” is actually a subclass of NSWindowController; it knows how to 
load a nib file already, so you should just leverage that rather than try to do 
it all yourself by hand.

All you should need to do is instantiate your window controller, invoke its 
-window method to force it to load its associated nib file, and then check that 
its outlets are wired up as you expect.

  — 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 arch...@mail-archive.com


Re: Getting Text Colors Right for Derived NSTextFieldCell under Various Conditions

2009-12-04 Thread Grant Erickson
On 12/4/09 6:59 PM, Jim Correia wrote:
> On Dec 4, 2009, at 1:52 PM, Grant Erickson wrote:
> 
>> I have implemented a custom class that derives from NSTextFieldCell to draw
>> status for an associated device (not unlike the network source list in the
>> Network System Preferences) overriding only:
> 
> [Š]
> 
>> The issue I am having is determining the correct set of conditionals to use
>> to determine when to invert the color of my text strings from
>> backgroundColor (when the cell is selected and the associated table has
>> focus) to textColor (when the cell is not selected or is selected and does
>> not have focus).
> 
> In general, the way to do this is to send -interiorBackgroundStyle to
> yourself, and pick a foreground text color suitable for the background.

Jim,

Thanks for the prompt reply. I forgot to mention one key element. The
subclass must support 10.4- and later so I cannot rely on 10.5- and later
APIs such as this.

Regards,

Grant


___

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

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

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

This email sent to arch...@mail-archive.com


Is it possible to pass an object to a NIB

2009-12-04 Thread DeNigris Sean
Hi list!

I'm writing a RubyCocoa app, but my question is on the Cocoa API...

I'm trying to unit test a view class.  As it is very thin (just delegates all 
work to the controller), all I want to check is that my connections (e.g. 
outlets and actions) are hooked up correctly.

I've been trying to:
1. Create an instance of my class
2. use NSBundle::loadNibFile: externalNameTable: withZone: to load the nib
3. check the connections

The docs for loadNibFile 
(http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSBundle_AppKitAdditions/Reference/Reference.html)
 seem to suggest that you can pass objects in:
"A name table whose keys identify objects associated with your program or the 
nib file. The newly unarchived objects from the nib file use this table to 
connect to objects in your program."

But I can't get it to work after hours!

This code is in ruby, but it's just bridged to the corresponding Cocoa calls:
view = MyView.new # subclass of NSWindowController
NSApplication.sharedApplication
top_level = [] # I've tried passing everything I could think of here:
- view # the object instance
- "My View" => view # NSDictionary with key 
object name in IB and value object instance
- MyView => view # NSDictionary with class name 
/ object entry

# I Also tried passing the object, and object-containing dictionaries 
below
# e.g. dictionaryWithObjects_forKeys [NSApp, top_level, view], 
[NSNibOwner, NSNibTopLevelObjects, "My View"]
context = NSDictionary::dictionaryWithObjects_forKeys [NSApp, 
top_level], [NSNibOwner, NSNibTopLevelObjects]

NibPath = 
".../RandomAppRuby.app/Contents/Resources/English.lproj/MainMenu.nib"

OSX::NSBundle::loadNibFile_externalNameTable_withZone NibPath, context, 
NSApp.zone

Thanks in advance for any guidance!

Sean DeNigris
s...@clipperadams.com



___

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

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

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

This email sent to arch...@mail-archive.com


Re: Getting Text Colors Right for Derived NSTextFieldCell under Various Conditions

2009-12-04 Thread Jim Correia
On Dec 4, 2009, at 1:52 PM, Grant Erickson wrote:

> I have implemented a custom class that derives from NSTextFieldCell to draw
> status for an associated device (not unlike the network source list in the
> Network System Preferences) overriding only:

[…]

> The issue I am having is determining the correct set of conditionals to use
> to determine when to invert the color of my text strings from
> backgroundColor (when the cell is selected and the associated table has
> focus) to textColor (when the cell is not selected or is selected and does
> not have focus).

In general, the way to do this is to send -interiorBackgroundStyle to yourself, 
and pick a foreground text color suitable for the background.

- Jim

___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSAffineTransform scaleBy not scaling

2009-12-04 Thread Shane
> Yes, you are transforming the pointsPath 'in place'.

That was it.

> I thought I'd mentioned the need to do that in my previous message: "You'll 
> need to regenerate a new path for each plot though, as the path will be 
> permanently changed by the above." I guess it wasn't clear what I meant by 
> that.
>

Yeah, I didn't pick up on that before.

> As you have it in the code now should be correct.
>

Thanks very much for your guidance here. It's now working better than
I had before where I was scaling each individual point. I like the way
it's put together much better now.

Thanks again.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSToolbar problem in 10.6

2009-12-04 Thread Peter Ammon

On Dec 4, 2009, at 2:13 PM, John Mikros wrote:

> Hello all,
> 
> I have a window with an NSToolbar attached.  The toolbar is created with 
> defaultItemIdentifiers being an empty NSArray, and then we add items via 
> insertItemWithItemIdentifier:atIndex:
> 
> All the item identifiers that are added to the toolbar are in the array 
> returned by toolbarAllowedItemIdentifiers:
> 
> However, the first toolbar item that I add does not show up in the toolbar.  
> The rest show up fine.  If you click the toolbar widget in the upper right of 
> the window to hide and then show the toolbar, then the missing item magically 
> appears in the toolbar.
> 
> This does not happen in 10.5.8.  Is there a way to force the toolbar to 
> refresh, as if the user hid and re-showed the toolbar?

Hi John,

I wasn't able to reproduce this problem in a test app.  Can you please provide 
a sample that reproduces it?  I can then suggest a workaround.

You might try using setDisplayMode: to alternate between display modes, as a 
way of refreshing it.

-Peter

___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSRuleEditor rows binding

2009-12-04 Thread Peter Ammon

On Dec 4, 2009, at 1:08 PM, Carter R. Harrison wrote:

> Apple's documentation for NSRuleEditor indicates that it exposes a binding 
> named "rows".  When I drag an NSRuleEditor onto my NSWindow in IB, I flip 
> over to the Bindings tab of the inspector and I don't see any bindings named 
> "rows".  Anybody else manage to setup an NSRuleEditor with bindings?

The "rows" binding doesn't make much sense for NSPredicateEditor, so it's not 
available in IB.  It is better to use the "value" binding; the value is an 
NSPredicate.

-Peter


___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSAffineTransform scaleBy not scaling

2009-12-04 Thread Graham Cox

On 05/12/2009, at 10:59 AM, Shane wrote:

> Anyone see anything wrong that I'm doing?


Yes, you are transforming the pointsPath 'in place'. You need to make a copy of 
the original path, apply the transform to it and draw the copy. Making a copy 
every time in drawRect: should be OK unless your path is very, very complicated 
- the copy is always going to be much faster than the rendering so don't worry 
about performance.

I thought I'd mentioned the need to do that in my previous message: "You'll 
need to regenerate a new path for each plot though, as the path will be 
permanently changed by the above." I guess it wasn't clear what I meant by that.

Also, when you get to applying both the translation and the scale together, 
watch the order. You want the translation to be independent of the scale, so 
apply it after scaling. That means, counterintuitively, that you do that first 
to NSAffineTransform, before the scaleBy step. I find it helpful to think of 
the operations that NSAffineTransform does to be in reverse order of how they 
appear in the code. In reality it does not do things as a series of steps but 
all at once, but the effect is as if it had applied the series of operations, 
but in reverse order.

As you have it in the code now should be correct.

--Graham


___

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

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

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

This email sent to arch...@mail-archive.com


Re: Best way to hook into the run loop?

2009-12-04 Thread Graham Cox

On 05/12/2009, at 5:02 AM, Quincey Morris wrote:

>> However, what about the bug where opening and closing a group but doing 
>> nothing in between creates a bogus empty undo task?  This comes into play 
>> when grouping things that occur over a series of events, for example mouse 
>> drags. It would be nice if I could just open a group on mouse down, and 
>> close it on mouse up. Depending on what the mouse actually does, it might 
>> not submit any undoable tasks to the undo manager. So this bug means that 
>> case has to be detected and the undo stack cleaned up. Ultimately this is 
>> the problem I'm trying to workaround - you would not believe how complicated 
>> it can get.
> 
> Weren't you talking about this in the context of writing your own undo 
> manager? In that case, detecting and discarding "empty" groups would be a 
> feature of your implementation.


Yes, my implementation doesn't have this bug.

But it's yet to be shown whether I can successfully replace NSUndoManager 
entirely (a whole new object, not a subclass) and have Cocoa accept it. There 
might be private parts of the framework using private NSUndoManager API that 
make this unworkable. Also, for all its flaws I'd prefer to work with a 
framework class than rewrite it, so I'm looking at both options.

> 
>> A related issue to the above is that if the mouse operation throws an 
>> exception (it generally shouldn't, but it can happen), the same group close 
>> and clean up has to be done. Otherwise Undo simply stops working because of 
>> the group imbalance.
> 
> If an exception is caught and handled, it's not clear why Mike's suggestion 
> should not still work perfectly. We don't have any reason, do we, to think 
> that a scheduled 'performSelector' is going to be interfered with by the 
> exception? (And you would, of course, *do* the 'performSelector' immediately 
> after opening the undo group, not later, so that it's always scheduled no 
> matter what happens later.)

Well, I've set up my implementation to work this way or as a runloop observer 
using a conditional compile, so I can experiment with both.

I have no reason to think that the exception should cause a problem either, and 
that's true in the case of NSUndoManager as well. However, my observation is 
that things do start acting 'weird' there when this happens, like the 
non-decrementing group level count. It's because I can't go into the black box 
of NSUndoManager that I have no idea why that's happening and what to do about 
it. Making my own undo manager means that at least I can have some hope of 
debugging it.

> Not sure if that's the only case you encounter where an undoable action spans 
> over more than one event. If it's just the mouse drag stuff why not 
> submitting the action when the mouse drag is complete?
> 
> From my point of view that would be the logical thing to do, adding undo 
> actions "along the trail" sounds wrong. What I expect to do in a drag is 
> changing a collection of objects from one state (before the drag) to another 
> (when the button is released). Everything in between is just interaction to 
> animate the drag but it doesn't change the state permanently, at least I 
> wouldn't expect it to.
> 
> As I said, I can't imagine a purpose for this. That doesn't mean that there 
> isn't something I hadn't thought of - in which case I'd like to be 
> enlightened.

Ideally you don't want undo tasks recorded "all along the trail". But consider 
that the data model might not know anything about what is changing a given 
property. Take the positioning of a shape in drawing by dragging it. The 
shape's 'location' property needs to be undoable, but this might be called once 
in response to setting it numerically through some UI, or repeatedly while 
dragging. The data model can't know when it should submit the undo task for the 
last time in a series because it can't tell when 'last' is. My solution to this 
is to implement task coalescing in the undo manager - if a series of tasks are 
submitted having identical targets and selectors within the same undo group, 
only the first is recorded and subsequent ones are dropped ('first' being easy 
to detect, 'last' being impossible). On the whole that works quite well, though 
there are a couple of cases where more than one property is changed repeatedly 
which prevents the coalescing from happening. That does result in a series of 
tasks which are 'replayed', which isn't perfect but still works.

If anyone can think of an elegant and straightforward alternative, please feel 
free to suggest it. I've found that the "obvious" solution of submitting an 
object's state at the start of a drag is actually really awkward and horrible 
in practice, since it requires that the controller needs to know in advance all 
of the relevant properties that will be changed, when in fact that's none of 
its business. The data model should be free to change anything it needs to in 
response to a higher-level command a

Re: NSAffineTransform scaleBy not scaling

2009-12-04 Thread Greg Guerin

Shane wrote:


So my thought is that somehow the transformations are not resetting to
the identity matrix, but they are as far as I can tell. Maybe, I'm
thinking, that the transforms are being added on top of each other as
the view resizes.



That's a fair description of what your code is doing.



NSAffineTransform *xform = [NSAffineTransform transform];

// curve starts off translated up 2 and over 2, correct.
// resizing view seems like x and y incr by 1 as view resizes.
[xform translateXBy:2.0 yBy:2.0];
//[xform scaleXBy:xFactor yBy:yFactor];

[pointsPath transformUsingAffineTransform:xform];



You create a transform.

You set it to translate by 2.

You apply the transform to the existing pointsPath.  (Each point in  
the path has the transform applied to it, modifying the point  
according to the transform.)


The above occurs each time drawRect: is called.  So after 10 calls to  
drawRect:, the points in the path have been translated a total of 10  
times.


You need to rethink things so the transforms aren't cumulative.

The way I'd approach this is to keep an original untransformed path,  
to which points are added.  This is copied to a drawable path, and  
that is the path that gets transformed and drawn.  Cache the drawable  
path in its transformed state.  Recompute the drawable path when a  
point is added, or when the transform changes.


  -- GG

___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSAffineTransform scaleBy not scaling

2009-12-04 Thread Shane
> That then just leaves you with the translation to deal with, for positioning 
> the scaled path where you want it.
>

I really hate to post this again, but I believe I'm doing it right,
but there's obviously something I'm not understanding. By trying to
figure out what's wrong w/ my scaling, I've simplified it to doing
transforms only which also shows the problem (new problem after making
the changes suggested).

I'm certain I have the destination bounds, the path bounds, and even
the scaleXBy: yBy: factors correct, but I'll just stick w/ how I'm
doing the 'translateXBy yBy:' and comment out the scaleXBy method. I
plot my line, and it shows in the view perfect, as expected. If I try
to resize the view, my plot starts to move incrementing by one,
translating +1 for both x and y. Whether I resize my NSView larger or
smaller, my curve moves to the upper right corner and then eventually
off the view, as if x and y in 'translateXBy: yBy' constantly
increment by one as I resize the view.

So my thought is that somehow the transformations are not resetting to
the identity matrix, but they are as far as I can tell. Maybe, I'm
thinking, that the transforms are being added on top of each other as
the view resizes.

Anyone see anything wrong that I'm doing?

- (void) drawRect:(NSRect) rect
{
NSRect bounds = [self bounds];

[[NSColor blackColor] setFill];
[NSBezierPath fillRect:bounds];

float xFactor = (bounds.size.width * 0.9) / maxXValue;
float yFactor = (bounds.size.height * 0.9) / maxYValue;

NSAffineTransform *xform = [NSAffineTransform transform];

// curve starts off translated up 2 and over 2, correct.
// resizing view seems like x and y incr by 1 as view resizes.
[xform translateXBy:2.0 yBy:2.0];
//[xform scaleXBy:xFactor yBy:yFactor];

[pointsPath transformUsingAffineTransform:xform];

[[NSColor whiteColor] setStroke];

[pointsPath setLineCapStyle:NSSquareLineCapStyle];
[pointsPath stroke];

return;
}

- (void) appendPoint:(NSPoint) point
{
if (firstPoint) {
[pointsPath moveToPoint:point];

firstPoint = NO;
}

[pointsPath lineToPoint:point];

return;
}

- (void) updateXMax:(double) maxX yMax:(double) maxY
{
maxXValue = maxX;
maxYValue = maxY;
}

This gets called for each point in my curve, which happens ~140 times.
My curve shows up as expected, then I resize the window and the curve
doesn't resize to the window, rather, it moves off the window in the
original size.

BOOL maxFlagDirty = NO;

NSNumber *mse = [NSNumber numberWithDouble:[[data mse] doubleValue]];
NSNumber *iters = [NSNumber numberWithInt:[[data iterations] intValue]];

if ([iters doubleValue] > maxXValue) {
maxXValue = [iters doubleValue];
maxFlagDirty = YES;
}

if ([mse doubleValue] > maxYValue) {
maxYValue = [mse doubleValue];
maxFlagDirty = YES;
}

if (maxFlagDirty) {
[graphView updateXMax:maxXValue yMax:maxYValue];
}

NSPoint point = NSMakePoint([iters floatValue], [mse floatValue]);

if ([self isWindowLoaded]) {
[graphView appendPoint:point];  

[graphView setNeedsDisplay:YES];
}
___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSRuleEditor rows binding

2009-12-04 Thread Jerry Krinock

On 2009 Dec 04, at 13:08, Carter R. Harrison wrote:

> Apple's documentation for NSRuleEditor indicates that it exposes a binding 
> named "rows".  When I drag an NSRuleEditor onto my NSWindow in IB, I flip 
> over to the Bindings tab of the inspector and I don't see any bindings named 
> "rows".  Anybody else manage to setup an NSRuleEditor with bindings?

No, but you should be able to bind to it in code using 
bind:toObject:withKeyPath:options:.  See the NSKeyValueBindingCreation Informal 
Protocol.

Also, it wouldn't surprise me that the binding is not available in Interface 
Builder.  Steve Jobs has referred to the Apple TV as a "hobby" project.  In my 
experience with NSPredicateEditor and NSRuleEditor, I have gotten the 
impression that these must similarly be "hobby" projects.  Innovative and 
actually quite powerful if you can figure out how to use them, but poorly 
documented, many unfinished features, and not many developers use them, so not 
much interest in finishing them.

Sincerely,

Jerry Krinock

___

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

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

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

This email sent to arch...@mail-archive.com


NSToolbar problem in 10.6

2009-12-04 Thread John Mikros
Hello all,

I have a window with an NSToolbar attached.  The toolbar is created with 
defaultItemIdentifiers being an empty NSArray, and then we add items via 
insertItemWithItemIdentifier:atIndex:

All the item identifiers that are added to the toolbar are in the array 
returned by toolbarAllowedItemIdentifiers:

However, the first toolbar item that I add does not show up in the toolbar.  
The rest show up fine.  If you click the toolbar widget in the upper right of 
the window to hide and then show the toolbar, then the missing item magically 
appears in the toolbar.

This does not happen in 10.5.8.  Is there a way to force the toolbar to 
refresh, as if the user hid and re-showed the toolbar?

thanks
-john
___

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

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

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

This email sent to arch...@mail-archive.com


Re: [iphone] Libxml2 with a wrapper to NSArray

2009-12-04 Thread Philip Vallone
Good point - Thanks



On Dec 4, 2009, at 1:32 PM, Alexander Spohr wrote:

> 
> Am 04.12.2009 um 10:09 schrieb Philip Vallone:
> 
>> Next I had a syntax error when declaring my NSArray and like you said it was 
>> pointing to an empty array:
>> 
>>  NSArray* result = [NSArray arrayWithArray:PerformXMLXPathQuery(xmlData, 
>> @"//mynode")];
> 
> Why are you putting the contents of the array you got into another array?
> Just keep the array you get:
> NSArray* result = PerformXMLXPathQuery(xmlData, @"//mynode");
> 
>   atze
> 

___

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

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

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

This email sent to arch...@mail-archive.com


NSRuleEditor rows binding

2009-12-04 Thread Carter R. Harrison
Apple's documentation for NSRuleEditor indicates that it exposes a binding 
named "rows".  When I drag an NSRuleEditor onto my NSWindow in IB, I flip over 
to the Bindings tab of the inspector and I don't see any bindings named "rows". 
 Anybody else manage to setup an NSRuleEditor with bindings?

Thanks
Carter
___

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

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

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

This email sent to arch...@mail-archive.com


Re: seg fault or not?

2009-12-04 Thread Kyle Sluder
On Fri, Dec 4, 2009 at 10:00 AM, Matt Neuburg  wrote:
> When I run my iPhone app on my device and quit it in the normal way (by
> clicking the home button), the gdb console reports "Debugger stopped.
> Program exited with status value:0.", which sounds fine.

I believe gdb attaches to Springboard, not directly to your application.

This question might be better sent to xcode-users.

--Kyle Sluder
___

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

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

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

This email sent to arch...@mail-archive.com


Getting Text Colors Right for Derived NSTextFieldCell under Various Conditions

2009-12-04 Thread Grant Erickson
I have implemented a custom class that derives from NSTextFieldCell to draw
status for an associated device (not unlike the network source list in the
Network System Preferences) overriding only:

- (void) drawInteriorWithFrame: (NSRect)inFrame inView: (NSView *)inView;

drawing the interior that includes two images, three strings and one drawn
graphic.

The end result is something that looks like the following (in terms of
bounding boxes):

.--... .--.
.--.|  |||.---.|  |
!__!|  |||!___!|  |
!__!!! !__!

Img  Image   StringsString  Drawn

The issue I am having is determining the correct set of conditionals to use
to determine when to invert the color of my text strings from
backgroundColor (when the cell is selected and the associated table has
focus) to textColor (when the cell is not selected or is selected and does
not have focus). I currently use:

- (void) drawInteriorWithFrame: (NSRect)inFrame
inView: (NSView *)inView
{
const bool isHighlighted = [self isHighlighted];
const bool notOff = ([self state] != 0);
const NSResponder * const firstResponder =
[[[self controlView] window] firstResponder];
const bool isFirstResponder = (inView == firstResponder);
const bool invertText = ((isHighlighted || notOff) &&
 isFirstResponder);

...

// Draw the title, status and value strings.

[self drawString: [theModel titleString]
  withAttributes: [self titleAttributes: invertText]
withRect: titleRect
  inView: inView];

which works in all cases except when I open a modal panel or sheet. I've
since modified the condition to add a check for

...
const bool controlWindowIsKey = [[[self controlView] window]
 isKeyWindow];
...
const bool invertText = ((isHighlighted || notOff) &&
 isFirstResponder &&
 controlWindowIsKey);

which seems to work correctly; however, this collectively strikes me as
"heavier" than I suspect optimal for this text inversion test. Any
recommendations on a better test or set thereof or is this more or less
"state of the art" for such a thing?

Regards,

Grant


___

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

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

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

This email sent to arch...@mail-archive.com


Re: [iphone] Libxml2 with a wrapper to NSArray

2009-12-04 Thread Alexander Spohr

Am 04.12.2009 um 10:09 schrieb Philip Vallone:

> Next I had a syntax error when declaring my NSArray and like you said it was 
> pointing to an empty array:
> 
>   NSArray* result = [NSArray arrayWithArray:PerformXMLXPathQuery(xmlData, 
> @"//mynode")];

Why are you putting the contents of the array you got into another array?
Just keep the array you get:
NSArray* result = PerformXMLXPathQuery(xmlData, @"//mynode");

atze

___

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

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

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

This email sent to arch...@mail-archive.com


Re: Why is "set" a class method of NSColor?

2009-12-04 Thread Matt Neuburg
On or about 12/4/09 10:07 AM, thus spake "Jens Alfke" :

> In the newer CoreGraphics APIs (that replaced Display PostScript),
> they switched to making context an explicit parameter of every drawing
> call.

Yes, I've noticed that, and it certainly makes it clearer what you're doing
(at the price of verbosity, of course). m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

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

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

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

This email sent to arch...@mail-archive.com


Re: Why is "set" a class method of NSColor?

2009-12-04 Thread Jens Alfke


On Dec 4, 2009, at 9:56 AM, Matt Neuburg wrote:


I have a vague feeling that, once again, it's a nomenclature thing. It
should really have a name that makes clear you're setting something  
about

the graphics context (like setForContext or something)...


In this context  "set" means "set the receiver to be used by the  
current graphics context". There are a couple of graphics-related  
classes that have this method.


I don't like this design, as it's not very object-oriented and relies  
on global state (the "current context"). It would be better to have a - 
setColor: method on NSGraphicsContext. It's been in AppKit forever,  
though, and I think it came from the PostScript model, where there is  
always a global graphics context that all operators implicitly refer  
to. In the newer CoreGraphics APIs (that replaced Display PostScript),  
they switched to making context an explicit parameter of every drawing  
call.


—Jens___

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

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

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

This email sent to arch...@mail-archive.com


seg fault or not?

2009-12-04 Thread Matt Neuburg
When I run my iPhone app on my device and quit it in the normal way (by
clicking the home button), the gdb console reports "Debugger stopped.
Program exited with status value:0.", which sounds fine.

But at the same time, the Organizer console says (references to my app's
name are expunged):

Fri Dec  4 09:35:07 unknown com.apple.launchd[1] : (xxx[0x3bef])
Bug: launchd_core_logic.c:2649 (23909):10
Fri Dec  4 09:35:07 unknown com.apple.launchd[1] : (xxx[0x3bef])
Working around 5020256. Assuming the job crashed.
Fri Dec  4 09:35:07 unknown com.apple.launchd[1] : (xxx[0x3bef])
Job appears to have crashed: Segmentation fault
Fri Dec  4 09:35:07 unknown com.apple.debugserver-43[776] : 1
[0308/1603]: error: ::read ( 7, 0x28091c, 1024 ) => -1 err = Bad file
descriptor (0x0009)
Fri Dec  4 09:35:07 unknown SpringBoard[39] : Application 'xxx'
exited abnormally with signal 11: Segmentation fault

Whom should I believe? Should I worry? And since I can't even get this to
break, how can I track it down? m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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

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

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

This email sent to arch...@mail-archive.com


Re: Saving position in NSTextView

2009-12-04 Thread Douglas Davidson


On Dec 4, 2009, at 9:30 AM, Pascal Harris wrote:

I am writing an application which, amongst other things, can be used  
to read text files.  These text files are rather long (could be more  
than 1MB), which isn't convenient for anyone to read in one  
sitting.  The text files are not editable.  I would like to be able  
to save the position in the text file so that a reader can come back  
to file at a later time and not have to hunt for the last sentence  
that they read.


My research shows that I can do half of what I need using NSRange -  
using scrollRangeToVisible it seems that I can scroll to a given  
range (allowing the reader to resume where they left off).  Sadly, I  
can't work out how I can save a range without the reader selecting  
text in the window first (hardly user friendly!).  I need this to  
work invisibly - i.e. the user closes the window, or the app, and  
when the window is reopened Presto!  the window contains the same  
view of the text as it did previously.


If I understand correctly, what you want to be able to determine is  
the range of text that is currently visible.  This can be a bit  
tricky, since depending on the arrangement of text, the visible text  
might not be a single contiguous range in the document, but one way to  
do this is to get the text view's visibleRect, convert it into  
container coordinates (by subtracting the textContainerOrigin), ask  
the layout manager for glyphRangeForBoundingRect:inTextContainer:, and  
convert the resulting glyph range to a character range.


Douglas Davidson

___

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

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

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

This email sent to arch...@mail-archive.com


Re: Best way to hook into the run loop?

2009-12-04 Thread Quincey Morris
On Dec 4, 2009, at 07:29, Graham Cox wrote:

> On 05/12/2009, at 2:19 AM, Mike Abdullah wrote:
> 
>> NSUndoManager works something like this:
>> 
>> 1. The first time an action is registered, an undo group begins.
>> 
>> 2. The group is scheduled to be closed using -[NSRunLoop 
>> performSelector:target:argument:order:modes:]. See the constants section of 
>> NSUndoManager for a little more detail.
>> 
>> As simple as that :)
> 
> 
> OK, that would appear to be the most obvious way to implement it.
> 
> However, what about the bug where opening and closing a group but doing 
> nothing in between creates a bogus empty undo task?  This comes into play 
> when grouping things that occur over a series of events, for example mouse 
> drags. It would be nice if I could just open a group on mouse down, and close 
> it on mouse up. Depending on what the mouse actually does, it might not 
> submit any undoable tasks to the undo manager. So this bug means that case 
> has to be detected and the undo stack cleaned up. Ultimately this is the 
> problem I'm trying to workaround - you would not believe how complicated it 
> can get.

Weren't you talking about this in the context of writing your own undo manager? 
In that case, detecting and discarding "empty" groups would be a feature of 
your implementation.

> A related issue to the above is that if the mouse operation throws an 
> exception (it generally shouldn't, but it can happen), the same group close 
> and clean up has to be done. Otherwise Undo simply stops working because of 
> the group imbalance.

If an exception is caught and handled, it's not clear why Mike's suggestion 
should not still work perfectly. We don't have any reason, do we, to think that 
a scheduled 'performSelector' is going to be interfered with by the exception? 
(And you would, of course, *do* the 'performSelector' immediately after opening 
the undo group, not later, so that it's always scheduled no matter what happens 
later.)


___

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

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

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

This email sent to arch...@mail-archive.com


Re: Why is "set" a class method of NSColor?

2009-12-04 Thread Matt Neuburg
On Thu, 3 Dec 2009 18:54:19 -0800, Jack Boyce  said:
>Argh, never mind.  I overlooked an important section of the Cocoa Drawing
>Guide.
>
>On Thu, Dec 3, 2009 at 6:46 PM, Jack Boyce  wrote:
>
>> I'm learning Cocoa, trying to understand certain "magical" features where
>> it isn't obvious how things work under the hood.  (KVO and isa-swizzling is
>> another prime example.)
>>
>> Can someone kindly explain, or point me to an explanation for, what's
>> really happening with:
>> [[NSColor blueColor] set];

I have a vague feeling that, once again, it's a nomenclature thing. It
should really have a name that makes clear you're setting something about
the graphics context (like setForContext or something)...

You might want to file a bug on the docs for not linking to the drawing
guide from where you were. m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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

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

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

This email sent to arch...@mail-archive.com


Re: A hillegass challenge

2009-12-04 Thread Greg Guerin

Michael de Haan wrote:

My question pertains to knowingly setting an object to NULL and  
then knowingly sending it a message as an acceptable technique. (If  
this is not done, drawRect will simply show the oval as if it was  
still being actively drawn).



Also see:

http://en.wikipedia.org/wiki/Null_Object_pattern

In this particular case, it's probably overkill to create a do- 
nothing class.  Other circumstances might make it more sensible.  For  
example, you have a collection that can't contain nil, yet you still  
need the do-nothing behavior from contained objects.


I also recommend changing your comment from the self-evident "sets  
the current bezierPath to nil", to instead give the REASON for  
setting bezierPath to nil, e.g. "a nil bezierPath always does nothing  
in drawRect:".


  -- GG

___

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

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

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

This email sent to arch...@mail-archive.com


Re: applicationShouldTerminate problem

2009-12-04 Thread Jens Alfke


On Dec 3, 2009, at 12:25 AM, proger proger wrote:

int ret = NSRunAlertPanel(@"Save the work?", @"Do you want save the  
work?",


A modal alert is the wrong UI here. It should be a sheet on the window.


I used Interface Builder to delegate NSApplication with my delegate
controller. But don't see any results.


It sounds like you just tried closing the window, not quitting the  
app. Those are different things.



But i'm still have problem because
then NSAlert is shown(i don't see my application window, it hides)


The method name includes "AFTER last window closed". So after the user  
closes the window, the app terminates. The window's already gone by  
that point.


What you need to add is the NSWindow delegate method - 
windowShouldClose:. This runs when the user tries to close the window.  
You should move your save/discard/cancel logic to a separate method,  
and then call it from -windowShoudlClose, and also from - 
applicationShouldTerminate:. (Strictly speaking the latter should call  
it on every open window, but it sounds like your app only has one  
window.)


Note that since sheets are not modal, your -windowShouldClose should  
always return NO if it puts up the sheet. Then your completion handler  
for the sheet can close the window (unless the user canceled.)


—Jens___

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

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

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

This email sent to arch...@mail-archive.com


Saving position in NSTextView

2009-12-04 Thread Pascal Harris
I am writing an application which, amongst other things, can be used to read 
text files.  These text files are rather long (could be more than 1MB), which 
isn't convenient for anyone to read in one sitting.  The text files are not 
editable.  I would like to be able to save the position in the text file so 
that a reader can come back to file at a later time and not have to hunt for 
the last sentence that they read.

My research shows that I can do half of what I need using NSRange - using 
scrollRangeToVisible it seems that I can scroll to a given range (allowing the 
reader to resume where they left off).  Sadly, I can't work out how I can save 
a range without the reader selecting text in the window first (hardly user 
friendly!).  I need this to work invisibly - i.e. the user closes the window, 
or the app, and when the window is reopened Presto!  the window contains the 
same view of the text as it did previously.  

Perplexed.  Any help that you can provide would be most welcome.  
___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSTextView & Horizontal Scrollbar bug

2009-12-04 Thread Ross Carter
On Dec 4, 2009, at 9:29 AM, Eric Gorr wrote:

> I've got a sample application at 
> http://ericgorr.net/cocoadev/TextViewNoWrap.zip which demonstrates the 
> problem I am seeing.
> 
> Basically, there is just a text view on a window with a horizontal scrollbar 
> which appears only when needed.
> 
> I have set this text view up based on the instructions found in the "Text 
> System User Interface Layer Programming Guide for Cocoa" (page 18 - Setting 
> Up a Horizontal Scroll Bar).
> 
> After ~77 characters or so, the horizontal scrollbar stops scrolling and I 
> can't make any of the text beyond that visible in my view. 
> 
> This looks like a bug to me and one that is likely already known.
> 
> Are there any known or suggested workarounds?
> 
> Thank you.

In IB you have set the maximum width of the text view to 478, so that is the 
limit you are running up against.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Best way to hook into the run loop?

2009-12-04 Thread Markus Spoettl
On Dec 4, 2009, at 4:29 PM, Graham Cox wrote:
> However, what about the bug where opening and closing a group but doing 
> nothing in between creates a bogus empty undo task?  This comes into play 
> when grouping things that occur over a series of events, for example mouse 
> drags. It would be nice if I could just open a group on mouse down, and close 
> it on mouse up. Depending on what the mouse actually does, it might not 
> submit any undoable tasks to the undo manager. So this bug means that case 
> has to be detected and the undo stack cleaned up. Ultimately this is the 
> problem I'm trying to workaround - you would not believe how complicated it 
> can get.


Not sure if that's the only case you encounter where an undoable action spans 
over more than one event. If it's just the mouse drag stuff why not submitting 
the action when the mouse drag is complete?

From my point of view that would be the logical thing to do, adding undo 
actions "along the trail" sounds wrong. What I expect to do in a drag is 
changing a collection of objects from one state (before the drag) to another 
(when the button is released). Everything in between is just interaction to 
animate the drag but it doesn't change the state permanently, at least I 
wouldn't expect it to.

As I said, I can't imagine a purpose for this. That doesn't mean that there 
isn't something I hadn't thought of - in which case I'd like to be enlightened.

Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to arch...@mail-archive.com

Re: NSSlider's setAltIncrementValue: broken?

2009-12-04 Thread Sean McBride
On 12/3/09 5:39 PM, Matt Neuburg said:

>>The docs for NSSlider's setAltIncrementValue: say "Sets the amount by
>>which the receiver modifies its value when the knob is Option-dragged".
>>It does not.
>
>Isn't the problem just a documentation bug?

Could be.  I'm not in a position to know if the docs are wrong or the
implementation is wrong.  :)  But I do know that I'm looking for the
documented behaviour, the actual behaviour I don't find so useful.

I guess it's off to Radar. :)  

Thanks for your replies Gregory and Matt.

--

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


___

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

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

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

This email sent to arch...@mail-archive.com


Re: Reboot? Slow First Run

2009-12-04 Thread gMail.com
Ok Jens,
you are right. Sure my comment sounds naive. I am not an expert developer.
All I wanted to say is that I would love to see a faster Finder and get a
faster seek time. That's all.

Regards
--
Leonardo

> Please don't make naive comments like this; it just makes you look
> foolish. I know we engineers all have a natural tendency to assume any
> problem we haven't personally worked on is trivial, but you really
> have to keep that in check


___

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

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

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

This email sent to arch...@mail-archive.com


Re: IKImageBrowserView D&D with IKImageBrowserNSDataRepresentationType

2009-12-04 Thread Micha Fuhrmann
Ok, thanks again, so far so good.

Now as I drag an image or multiple images it creates a thumb of the dragged 
item(s), but as I drag to the desktop there's no plus sign badge on the dragged 
items and as a drop on the desktop it doesn't accept. I guess what I need to 
get is a 

- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination{

And then perform the paste from my end. But I'm not receiving 
namesOfPromisedFilesDroppedAtDestination. I've looked in the sample code and 
the last example is from 2003.

Micha
On 4 déc. 2009, at 15:55, Thomas Goossens wrote:

> return NSDragOperationNone in the two methods below:
> 
> - (NSDragOperation)draggingEntered:(id )sender
> - (NSDragOperation)draggingUpdated:(id )sender
> 
> or invoke this during the setup of your IKImageBrowserView:
> 
> registerForDraggedTypes:nil
> 
> -- Thomas
> 
> On Dec 4, 2009, at 3:44 PM, Micha Fuhrmann wrote:
> 
>> Ha yes,
>> 
>> I'm doing a from only. Now I've filled the pasteboard with my NSData objects 
>> for NSFilesPromisePboardType. Which methods should I implement if I don't 
>> want any drops enabled within the image browser but only to the finder?
>> 
>> Any direction appreciated.
>> 
>> On 4 déc. 2009, at 14:48, Thomas Goossens wrote:
>> 
>>> Hi Micha,
>>> 
>>> Are you trying to drag from the IKImageBrowserView or into the 
>>> IKImageBrowserView ?
>>> 
>>> if from: you need to fill the pasteboard by implementing the datasource 
>>> method:
>>> - (NSUInteger) imageBrowser:(IKImageBrowserView *) aBrowser 
>>> writeItemsAtIndexes:(NSIndexSet *) itemIndexes toPasteboard:(NSPasteboard 
>>> *)pasteboard;
>>> 
>>> if into: there should be no difference between 
>>> IKImageBrowserNSDataRepresentationType and 
>>> IKImageBrowserPathRepresentationType.
>>> 
>>> --Thomas
>>> 
>>> On Dec 4, 2009, at 2:41 PM, Micha Fuhrmann wrote:
>>> 
 Dear All,
 
 Im using a IKImageBrowserView and trying to implement D&D. The image 
 object I'm using is of IKImageBrowserNSDataRepresentationType. If I use 
 IKImageBrowserPathRepresentationType D&D works fine.
 
 But with IKImageBrowserNSDataRepresentationType none of the delegates 
 methods gets called:
 
 - (NSDragOperation)draggingEntered:(id )sender
 - (NSDragOperation)draggingUpdated:(id )sender
 - (BOOL) performDragOperation:(id )sender
 
 I've tried 
 
 IKImageBrowserView  -> registerForDraggedTypes:[NSArray arrayWithObject: 
 NSFilesPromisePboardType]
 
 To no avail. Any help as to which direction to take would be great.
 
 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/tgoossens%40mac.com
 
 This email sent to tgooss...@mac.com
>>> 
>> 
> 

___

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

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

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

This email sent to arch...@mail-archive.com


Re: Outline View.

2009-12-04 Thread Dave DeLong
Here's one I created in about 10 minutes:  Create a regular Cocoa app, drop an 
outline view into the window, and hook it up to the AppDelegate for its 
datasource and its delegate.

The following four methods will allow you to walk your entire file hierarchy.  
Yes there's a memory leak, and this probably isn't the smartest way to be doing 
stuff, but the point is to show how it works.  =)

- (NSInteger)outlineView:(NSOutlineView *)outlineView 
numberOfChildrenOfItem:(id)item {
if (item == nil) { return 1; }
BOOL isDir = NO;
if ([[NSFileManager defaultManager] fileExistsAtPath:item 
isDirectory:&isDir] && isDir == YES) {
return [[[NSFileManager defaultManager] 
contentsOfDirectoryAtPath:item error:nil] count];
}
return 0;
}

- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index 
ofItem:(id)item {
if (item == nil) { return @"/"; }
NSArray * children = [[NSFileManager defaultManager] 
contentsOfDirectoryAtPath:item error:nil];
//this has to be a retained object, otherwise the item will be 
destroyed on the next runloop cycle
return [[item stringByAppendingPathComponent:[children 
objectAtIndex:index]] retain];
}

- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
BOOL isDir = NO;
if ([[NSFileManager defaultManager] fileExistsAtPath:item 
isDirectory:&isDir] && isDir == YES) { return YES; }
return NO;
}

- (id)outlineView:(NSOutlineView *)outlineView 
objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item {
return [[NSFileManager defaultManager] displayNameAtPath:item];
}

Enjoy!

Dave

On Dec 3, 2009, at 9:37 PM, Sandro Noël wrote:

> On 2009-12-03, at 11:07 PM, Graham Cox wrote:
>> 
>> http://apptree.net/gcfolderbrowser.htm
>> 
>> 
>> hth,
>> 
>> --Graham
>> 
> Graham thanks for the link, 
> the component is deprecated thow.
> but it's a good enough example.


smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to arch...@mail-archive.com

Re: Best way to hook into the run loop?

2009-12-04 Thread Graham Cox

On 05/12/2009, at 2:19 AM, Mike Abdullah wrote:

> NSUndoManager works something like this:
> 
> 1. The first time an action is registered, an undo group begins.
> 
> 2. The group is scheduled to be closed using -[NSRunLoop 
> performSelector:target:argument:order:modes:]. See the constants section of 
> NSUndoManager for a little more detail.
> 
> As simple as that :)


OK, that would appear to be the most obvious way to implement it.

However, what about the bug where opening and closing a group but doing nothing 
in between creates a bogus empty undo task?  This comes into play when grouping 
things that occur over a series of events, for example mouse drags. It would be 
nice if I could just open a group on mouse down, and close it on mouse up. 
Depending on what the mouse actually does, it might not submit any undoable 
tasks to the undo manager. So this bug means that case has to be detected and 
the undo stack cleaned up. Ultimately this is the problem I'm trying to 
workaround - you would not believe how complicated it can get.

A related issue to the above is that if the mouse operation throws an exception 
(it generally shouldn't, but it can happen), the same group close and clean up 
has to be done. Otherwise Undo simply stops working because of the group 
imbalance.

It's really troublesome because so much of what's going on inside NSUndoManager 
is opaque to the app, debugger and everything else. And what's going on is 
definitely weird - like calling -endUndoGrouping and having the level stuck at 
1 before and after.

I've had so much grief with the UM that I'm basically prepared to write my own 
- in fact I have it 99% working now (passes all its unit tests) just need to 
see if it will work in a real situation.

--Graham


___

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

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

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

This email sent to arch...@mail-archive.com


Re: Best way to hook into the run loop?

2009-12-04 Thread Mike Abdullah
NSUndoManager works something like this:

1. The first time an action is registered, an undo group begins.

2. The group is scheduled to be closed using -[NSRunLoop 
performSelector:target:argument:order:modes:]. See the constants section of 
NSUndoManager for a little more detail.

As simple as that :)

On 4 Dec 2009, at 04:17, Graham Cox wrote:

> As my undo woes continue and multiply, I'm working on my own undo 
> implementation, as least as a back-up strategy.
> 
> One thing I'd like to do is to match NSUndoManager's ability to automatically 
> open and close groups as the run loop cycles. What's the best way to do this?
> 
> What's needed is a way to call a class method of my undo manager at the start 
> and end of the every cycle of the main run loop, before any events are 
> dispatched.
> 
> I notice that NSUndoManager has a 'run loop modes' property but it's unclear 
> where and how that is used.
> 
> Thanks for any help,
> 
> --Graham___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
> 
> This email sent to cocoa...@mikeabdullah.net

___

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

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

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

This email sent to arch...@mail-archive.com


Re: Outline View.

2009-12-04 Thread Clint Shryock
Try reading up on and using NSTreeController, specifically
"Providing Providing Controller Content" in the Cocoa Bindings Programming
topics:

http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/CocoaBindings/Concepts/CntrlContent.html#//apple_ref/doc/uid/TP40002147

otherwise Outline View programing topics should get you what you want,
though with out bindings:
http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/OutlineView/OutlineView.html#//apple_ref/doc/uid/1023

There's also sample code (though it is meant to demonstrate drag and drop)
that may help you:
http://developer.apple.com/mac/library/samplecode/DragNDropOutlineView/index.html#//apple_ref/doc/uid/DTS40008831

+Clint

On Thu, Dec 3, 2009 at 10:37 PM, Sandro Noël 
wrote:
>
> On 2009-12-03, at 11:07 PM, Graham Cox wrote:
> >
> > http://apptree.net/gcfolderbrowser.htm
> >
> >
> > hth,
> >
> > --Graham
> >
> Graham thanks for the link,
> the component is deprecated thow.
> but it's a good enough example.
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/cts3e1%40gmail.com
>
> This email sent to cts...@gmail.com
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Best way to hook into the run loop?

2009-12-04 Thread Jason Foreman

On Dec 4, 2009, at 7:18 AM, Graham Cox wrote:

> I'm looking at the docs now, and for this use, it seems I would want 
> kCFRunLoopAfterWaiting to OPEN any undo groups, because that's just before 
> processing an event, but it's a little less clear when I should do the 
> automatic close. Presumably once the event is finished being handled the loop 
> continues, so would kCFRunLoopBeforeTimers effectively represent the end (as 
> well as the very start) of a given event cycle?

I think what you say sounds right.  A look through the CF sources might provide 
some enlightenment here too.  I would try kCFRunLoopBeforeTimers to see if that 
works for your use case.


> Otherwise how would I know when an event has been completely handled?

The only other thing that comes to mind would be to create some autoreleased 
object when you open the undo group which closes the undo group when released, 
since each cycle of the run loop should drain the autorelease pool.  This feels 
like a hack though, and it of course doesn't work if you need to support 
garbage collection.


Jason




smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to arch...@mail-archive.com

Re: IKImageBrowserView D&D with IKImageBrowserNSDataRepresentationType

2009-12-04 Thread Thomas Goossens
return NSDragOperationNone in the two methods below:

- (NSDragOperation)draggingEntered:(id )sender
- (NSDragOperation)draggingUpdated:(id )sender

or invoke this during the setup of your IKImageBrowserView:

registerForDraggedTypes:nil

-- Thomas

On Dec 4, 2009, at 3:44 PM, Micha Fuhrmann wrote:

> Ha yes,
> 
> I'm doing a from only. Now I've filled the pasteboard with my NSData objects 
> for NSFilesPromisePboardType. Which methods should I implement if I don't 
> want any drops enabled within the image browser but only to the finder?
> 
> Any direction appreciated.
> 
> On 4 déc. 2009, at 14:48, Thomas Goossens wrote:
> 
>> Hi Micha,
>> 
>> Are you trying to drag from the IKImageBrowserView or into the 
>> IKImageBrowserView ?
>> 
>> if from: you need to fill the pasteboard by implementing the datasource 
>> method:
>> - (NSUInteger) imageBrowser:(IKImageBrowserView *) aBrowser 
>> writeItemsAtIndexes:(NSIndexSet *) itemIndexes toPasteboard:(NSPasteboard 
>> *)pasteboard;
>> 
>> if into: there should be no difference between 
>> IKImageBrowserNSDataRepresentationType and 
>> IKImageBrowserPathRepresentationType.
>> 
>> --Thomas
>> 
>> On Dec 4, 2009, at 2:41 PM, Micha Fuhrmann wrote:
>> 
>>> Dear All,
>>> 
>>> Im using a IKImageBrowserView and trying to implement D&D. The image object 
>>> I'm using is of IKImageBrowserNSDataRepresentationType. If I use 
>>> IKImageBrowserPathRepresentationType D&D works fine.
>>> 
>>> But with IKImageBrowserNSDataRepresentationType none of the delegates 
>>> methods gets called:
>>> 
>>> - (NSDragOperation)draggingEntered:(id )sender
>>> - (NSDragOperation)draggingUpdated:(id )sender
>>> - (BOOL) performDragOperation:(id )sender
>>> 
>>> I've tried 
>>> 
>>> IKImageBrowserView  -> registerForDraggedTypes:[NSArray arrayWithObject: 
>>> NSFilesPromisePboardType]
>>> 
>>> To no avail. Any help as to which direction to take would be great.
>>> 
>>> 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/tgoossens%40mac.com
>>> 
>>> This email sent to tgooss...@mac.com
>> 
> 

___

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

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

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

This email sent to arch...@mail-archive.com


Re: IKImageBrowserView D&D with IKImageBrowserNSDataRepresentationType

2009-12-04 Thread Micha Fuhrmann
Ha yes,

I'm doing a from only. Now I've filled the pasteboard with my NSData objects 
for NSFilesPromisePboardType. Which methods should I implement if I don't want 
any drops enabled within the image browser but only to the finder?

Any direction appreciated.

On 4 déc. 2009, at 14:48, Thomas Goossens wrote:

> Hi Micha,
> 
> Are you trying to drag from the IKImageBrowserView or into the 
> IKImageBrowserView ?
> 
> if from: you need to fill the pasteboard by implementing the datasource 
> method:
> - (NSUInteger) imageBrowser:(IKImageBrowserView *) aBrowser 
> writeItemsAtIndexes:(NSIndexSet *) itemIndexes toPasteboard:(NSPasteboard 
> *)pasteboard;
> 
> if into: there should be no difference between 
> IKImageBrowserNSDataRepresentationType and 
> IKImageBrowserPathRepresentationType.
> 
> --Thomas
> 
> On Dec 4, 2009, at 2:41 PM, Micha Fuhrmann wrote:
> 
>> Dear All,
>> 
>> Im using a IKImageBrowserView and trying to implement D&D. The image object 
>> I'm using is of IKImageBrowserNSDataRepresentationType. If I use 
>> IKImageBrowserPathRepresentationType D&D works fine.
>> 
>> But with IKImageBrowserNSDataRepresentationType none of the delegates 
>> methods gets called:
>> 
>> - (NSDragOperation)draggingEntered:(id )sender
>> - (NSDragOperation)draggingUpdated:(id )sender
>> - (BOOL) performDragOperation:(id )sender
>> 
>> I've tried 
>> 
>> IKImageBrowserView  -> registerForDraggedTypes:[NSArray arrayWithObject: 
>> NSFilesPromisePboardType]
>> 
>> To no avail. Any help as to which direction to take would be great.
>> 
>> 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/tgoossens%40mac.com
>> 
>> This email sent to tgooss...@mac.com
> 

___

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

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

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

This email sent to arch...@mail-archive.com


Re: A hillegass challenge

2009-12-04 Thread Michael de Haan

On Dec 4, 2009, at 12:05 AM, Rob Keniger wrote:

> 
> On 04/12/2009, at 5:55 PM, Seth Willits wrote:
> 
>>> My question pertains to knowingly setting an object to NULL and then 
>>> knowingly sending it a message as an acceptable technique.
>> 
>> As general answer: Yep. Happens all the time.
> 
> 
> As Seth points out, this is perfectly normal. However, you should generally 
> use "nil" instead of "NULL" for nil objects in Objective-C.
> 
> It doesn't matter from a technical point of view (they're both the same) but 
> it's the accepted coding style.
> 
> --
> Rob Keniger


Rob and Seth, thank you. Progress!  
:-)___

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

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

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

This email sent to arch...@mail-archive.com


NSTextView & Horizontal Scrollbar bug

2009-12-04 Thread Eric Gorr
I've got a sample application at 
http://ericgorr.net/cocoadev/TextViewNoWrap.zip which demonstrates the problem 
I am seeing.

Basically, there is just a text view on a window with a horizontal scrollbar 
which appears only when needed.

I have set this text view up based on the instructions found in the "Text 
System User Interface Layer Programming Guide for Cocoa" (page 18 - Setting Up 
a Horizontal Scroll Bar).

After ~77 characters or so, the horizontal scrollbar stops scrolling and I 
can't make any of the text beyond that visible in my view. 

This looks like a bug to me and one that is likely already known.

Are there any known or suggested workarounds?

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 arch...@mail-archive.com


Re: NSHTTPCookieStorage to implement "Sign Out" functionality

2009-12-04 Thread Jerry Krinock

On 2009 Dec 01, at 15:29, Jesse Grosjean wrote:

> Does anyone know how to consistently implement "log out" functionality
> in an app that interacts with a web service?

Just send a HTTP GET request to 

   https://www.google.com/accounts/Logout

Works for me.  I believe we're talking about the same cookie-based Google 
login, but maybe I'm wrong.  Let us know, because I've never quite understood 
this and would like to do better.


___

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

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

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

This email sent to arch...@mail-archive.com


Re: Core Data modeling question

2009-12-04 Thread Jerry Krinock

On 2009 Dec 04, at 04:37, Mark Smith wrote:

> However... when I do a unidirectional one to many relationship, the compiler 
> (rightly) complains as I do not have inverse relationships.  However, it 
> makes no sense to me to clutter up my address object with pointers back to 
> "company" and "contact" and perhaps any other entity down the line that may 
> need an "address."

The conventional solution to this "problem" is to ignore your common sense and 
just add the inverse relationships to your data model anyhow.  I don't believe 
that any pointers will be created unless Core Data feels like it needs them 
while running, which if your common sense is correct, it won't.

___

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

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

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

This email sent to arch...@mail-archive.com


Re: beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector: on 10.6

2009-12-04 Thread Jerry Krinock

On 2009 Dec 03, at 22:40, Charles Burnstagger wrote:

> What changes were made to NSSavePanel 
> beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:

Hidden in the Release Notes as usual :)

Click this link and search its text for "NSSavePanel"

http://developer.apple.com/mac/library/releasenotes/Cocoa/AppKit.html

___

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

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

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

This email sent to arch...@mail-archive.com


Re: IKImageBrowserView D&D with IKImageBrowserNSDataRepresentationType

2009-12-04 Thread Thomas Goossens
Hi Micha,

Are you trying to drag from the IKImageBrowserView or into the 
IKImageBrowserView ?

if from: you need to fill the pasteboard by implementing the datasource method:
- (NSUInteger) imageBrowser:(IKImageBrowserView *) aBrowser 
writeItemsAtIndexes:(NSIndexSet *) itemIndexes toPasteboard:(NSPasteboard 
*)pasteboard;

if into: there should be no difference between 
IKImageBrowserNSDataRepresentationType and IKImageBrowserPathRepresentationType.

--Thomas

On Dec 4, 2009, at 2:41 PM, Micha Fuhrmann wrote:

> Dear All,
> 
> Im using a IKImageBrowserView and trying to implement D&D. The image object 
> I'm using is of IKImageBrowserNSDataRepresentationType. If I use 
> IKImageBrowserPathRepresentationType D&D works fine.
> 
> But with IKImageBrowserNSDataRepresentationType none of the delegates methods 
> gets called:
> 
> - (NSDragOperation)draggingEntered:(id )sender
> - (NSDragOperation)draggingUpdated:(id )sender
> - (BOOL) performDragOperation:(id )sender
> 
> I've tried 
> 
> IKImageBrowserView  -> registerForDraggedTypes:[NSArray arrayWithObject: 
> NSFilesPromisePboardType]
> 
> To no avail. Any help as to which direction to take would be great.
> 
> 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/tgoossens%40mac.com
> 
> This email sent to tgooss...@mac.com

___

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

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

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

This email sent to arch...@mail-archive.com


IKImageBrowserView D&D with IKImageBrowserNSDataRepresentationType

2009-12-04 Thread Micha Fuhrmann
Dear All,

Im using a IKImageBrowserView and trying to implement D&D. The image object I'm 
using is of IKImageBrowserNSDataRepresentationType. If I use 
IKImageBrowserPathRepresentationType D&D works fine.

But with IKImageBrowserNSDataRepresentationType none of the delegates methods 
gets called:

- (NSDragOperation)draggingEntered:(id )sender
- (NSDragOperation)draggingUpdated:(id )sender
- (BOOL) performDragOperation:(id )sender

I've tried 

IKImageBrowserView  -> registerForDraggedTypes:[NSArray arrayWithObject: 
NSFilesPromisePboardType]

To no avail. Any help as to which direction to take would be great.

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 arch...@mail-archive.com


Re: Best way to hook into the run loop?

2009-12-04 Thread Graham Cox
That looks perfect, thanks for the pointer.

I'm looking at the docs now, and for this use, it seems I would want 
kCFRunLoopAfterWaiting to OPEN any undo groups, because that's just before 
processing an event, but it's a little less clear when I should do the 
automatic close. Presumably once the event is finished being handled the loop 
continues, so would kCFRunLoopBeforeTimers effectively represent the end (as 
well as the very start) of a given event cycle?

Otherwise how would I know when an event has been completely handled?

--Graham




On 04/12/2009, at 4:13 PM, Jason Foreman wrote:

> 
> On Dec 3, 2009, at 10:17 PM, Graham Cox wrote:
> 
>> One thing I'd like to do is to match NSUndoManager's ability to 
>> automatically open and close groups as the run loop cycles. What's the best 
>> way to do this?
> 
> Possibly by using a CFRunLoopObserver.  You can look into 
> CFRunLoopObserverCreate and the related documentation.  This will allow you 
> to observe various stages of the run loop cycle.
> 
> 
>> I notice that NSUndoManager has a 'run loop modes' property but it's unclear 
>> where and how that is used.
> 
> The modes are basically filters for which input sources get processed by a 
> run loop cycle.  There is a run loop mode used by modal panels and another 
> for mouse tracking.  An undo manager could use this mode to avoid (or 
> explicitly allow) registering undos during a mouse drag, for example.
> 
> 
> Jason
> 
> 

___

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

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

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

This email sent to arch...@mail-archive.com


Core Data modeling question

2009-12-04 Thread Mark Smith
Good morning,

I am trying to figure out the best way to model a Core Data relationship.

Essentially, I am trying to have an "Address" object that can be referenced by 
"Contacts" and "Companies." 

In other words, contact entities should have multiple addresses (one to many), 
and company entities should have multiple addresses as well.

However... when I do a unidirectional one to many relationship, the compiler 
(rightly) complains as I do not have inverse relationships.  However, it makes 
no sense to me to clutter up my address object with pointers back to "company" 
and "contact" and perhaps any other entity down the line that may need an 
"address."

Anybody solved this one and have some advice?  Is this a place for a "fetched 
property?"

Thanks in advance,

Best Regards,

Mark Smith



___

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

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

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

This email sent to arch...@mail-archive.com


_NSLayoutTreeSetOutsideDrawsUponLineFragmentAtGlyphIndex

2009-12-04 Thread Gerriet M. Denkmann
I have an app which contains 3 NSTextViews.

Sometimes I get the following line:
 !!! _NSLayoutTreeSetOutsideDrawsUponLineFragmentAtGlyphIndex invalid glyph 
index 196
(the number varies. If I get this line, I get it a 3 times with the same number)

Looking into Console.app I see that TextEdit also produces this same line.

Any idea what this means and how I can debug this?

The problem: it happens sometimes, but is not reproducible.


Kind regards,

Gerriet.

___

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

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

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

This email sent to arch...@mail-archive.com


Re: applicationShouldTerminate problem

2009-12-04 Thread proger proger
Thanks for point. Now I'm experimenting with document based cocoa
application. I'm added NSTextView to my application interface, but after i
load file i didn't see anything. My code:

- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
[super windowControllerDidLoadNib:aController];
// if i add [textView setString: @"test"] << i can see this text on the
first window.
}

- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
{
NSData *data = [textView RTFFromRange:NSMakeRange(0,
  [[textView
textStorage] length])];
if (!data && outError) {
*outError = [NSError errorWithDomain:NSCocoaErrorDomain
code:NSFileWriteUnknownError
userInfo:nil];
}
return data;
}

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName
error:(NSError **)outError
{
BOOL readSuccess = NO;
NSAttributedString *fileContents = [[NSAttributedString alloc]
initWithData:data options:NULL
documentAttributes:NULL
error:outError];
if ( outError != NULL ) {
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain
code:unimpErr userInfo:NULL];
}
if (fileContents) {
readSuccess = YES;
[[textView textStorage] setAttributedString:fileContents];
NSLog(@"%@", fileContents) ;  // I can see output in console, but
not on textView
[fileContents release];
}
return readSuccess;
}

and my mydocument.h

#import 

@interface MyDocument : NSDocument
{
IBOutlet id textView ;
NSData * dataFromFile;
}
@end

Seems like i need to make additional connections in Interface Builder ?

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 arch...@mail-archive.com


Re: MacResearch Tutorial on beginning a Cocoa/iPhone app.

2009-12-04 Thread Philip Vallone
Thanks Brian,

This looks very useful.

Regards,

Phil

On Dec 3, 2009, at 5:25 PM, Brian Dittmer wrote:

> If you need graphing/charting on either iPhone or OSX then checkout
> CorePlot, it's a rather impressive and mature library for generating
> graphs and charts.
> 
> http://code.google.com/p/core-plot/
> 
> Cheers,
> Brian
> 
> 
> On Thu, Dec 3, 2009 at 4:38 PM, Karolis Ramanauskas  
> wrote:
>> Agreed, no network connection no graph! ;) What if I need to update my graph
>> live?
>> 
>> On Thu, Dec 3, 2009 at 2:48 PM, Philip Vallone
>> wrote:
>> 
>>> This post is very misleading. The tutorial is called "Using VVI for
>>> Graphing on iPhone" however there is no graphing. The graph is pulled in
>>> from the website and viewed through the UIWebView.
>>> 
>>> Just my thoughts...
>>> 
>>> 
>>> 
>>> 
>>> On Dec 3, 2009, at 12:09 PM, lbland wrote:
>>> 
 hi-
 
 Occasionally I see a trouble-getting-started post on this list. There is
>>> a great Cocoa/Xcode/iPhone tutorial on MacResearch:
 
 Using VVI for Graphing on iPhone
 http://www.macresearch.org/using-vvi-graphing-iphone
 
 Explaining in precise detail how to make a simple iPhone app. I may be a
>>> bit partial to the writing style though :-)
 
 thanks!-
 
 -lance
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 
>>> http://lists.apple.com/mailman/options/cocoa-dev/philip.vallone%40verizon.net
 
 This email sent to philip.vall...@verizon.net
>>> 
>>> ___
>>> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>> 
>>> Please do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>> 
>>> Help/Unsubscribe/Update your Subscription:
>>> http://lists.apple.com/mailman/options/cocoa-dev/karolisr%40gmail.com
>>> 
>>> This email sent to karol...@gmail.com
>>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/brian.t.dittmer%40gmail.com
>> 
>> This email sent to brian.t.ditt...@gmail.com
>> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/philip.vallone%40verizon.net
> 
> This email sent to philip.vall...@verizon.net

___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSSpellChecker and checkSpellingOfString problems (solved... embarrassingly)

2009-12-04 Thread Keith Blount
Please ignore all previous messages about NSSpellChecker. I wish there were a 
way to withdraw mails after they've been sent, because it turns out I'm an 
idiot.

This is actually a *feature* of Snow Leopard, not a bug. The misspelled words I 
was using and that my user had sent me were all fine in a different language; 
and because the spell-checker was set to "Automatic by Language" (not English 
as I had thought and said here), it wasn't reporting a problem until there were 
more English words. Had I a better (or any grasp) of Italian I might have 
realised this earlier.

Sorry for wasting your time.
Best,
Keith 

---

Hello,

I have an NSTextView subclass that provides a custom contextual menu by 
overriding -menuForEvent:. Because I override this, I have to provide any menu 
items I want to retain from the original menu myself. Mostly, that's not a 
problem, but I want to keep the spell checking options at the top of the menu 
as well. I thought I had this covered. This is what I'm doing:


// Is there a selection?
if (selRange.length > 0 && selRange.location < [text length])
{
// If so, check to see if the selected range constitutes a misspelled word.
NSSpellChecker *spellChecker = [NSSpellChecker sharedSpellChecker];
NSRange misspelledRange = [spellChecker checkSpellingOfString:[[text 
string] substringWithRange:selRange] startingAt:0];

// Detected misspelled word?
if (misspelledRange.length == selRange.length)
{
// Get suggestions.
NSArray *suggestions = [spellChecker guessesForWord:[[text string] 
substringWithRange:selRange]];

// Are there any suggestions?
if ([suggestions count] > 0)
{
// If so, add them to the menu with an appropriate action.
}
else
{
// Otherwise insert the "No Guesses Found" item.
}
}

I thought all of this was working fine. However, a user has just pointed out to 
me that it doesn't work for all misspellings... Which is very strange. The 
problem comes down to NSSpellChecker's -checkSpellingOfString:. This returns an 
NSNotFound range for certain misspellings.

For instance:

Try typing "accade" into TextEdit (I'm assuming English as the language here, 
of course). It is underlined in red, and ctrl-clicking on it brings up a list 
of suggestions. So the system recognises it as a misspelling, a word that it 
doesn't know.

Now try this in any test app:

NSRange range = [[NSSpellChecker sharedSpellChecker] 
checkSpellingOfString:@"accade" startingAt:0];
NSLog (@"NSStringFromRange(range));

range will be (NSNotFound,0).

I don't understand why, though. Why isn't NSSpellChecker returning this as a 
misspelling? Am I missing something obvious? Is there a better way to insert 
the spelling suggestions at the top of the menu?

Thanks and all the best,
Keith


  
___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSSpellChecker and checkSpellingOfString problems

2009-12-04 Thread Keith Blount
Just an update on this. It seems to be a Snow Leopard bug, as I can now 
reproduce it in TextEdit. If you try typing "accede" or "accademia" in an empty 
TextEdit window, then ctrl-click on them to get suggestions, you get nothing - 
they aren't caught as misspelled. If you do the same when the misspelled word 
is at the end of the line, you get suggestions. But I tried it on Tiger and 
everything works fine there. Off to file a bug report with Apple. :(


---

Hello,

I have an NSTextView subclass that provides a custom contextual menu by 
overriding -menuForEvent:. Because I override this, I have to provide any menu 
items I want to retain from the original menu myself. Mostly, that's not a 
problem, but I want to keep the spell checking options at the top of the menu 
as well. I thought I had this covered. This is what I'm doing:


// Is there a selection?
if (selRange.length > 0 && selRange.location < [text length])
{
// If so, check to see if the selected range constitutes a misspelled word.
NSSpellChecker *spellChecker = [NSSpellChecker sharedSpellChecker];
NSRange misspelledRange = [spellChecker checkSpellingOfString:[[text 
string] substringWithRange:selRange] startingAt:0];

// Detected misspelled word?
if (misspelledRange.length == selRange.length)
{
// Get suggestions.
NSArray *suggestions = [spellChecker guessesForWord:[[text string] 
substringWithRange:selRange]];

// Are there any suggestions?
if ([suggestions count] > 0)
{
// If so, add them to the menu with an appropriate action.
}
else
{
// Otherwise insert the "No Guesses Found" item.
}
}

I thought all of this was working fine. However, a user has just pointed out to 
me that it doesn't work for all misspellings... Which is very strange. The 
problem comes down to NSSpellChecker's -checkSpellingOfString:. This returns an 
NSNotFound range for certain misspellings.

For instance:

Try typing "accade" into TextEdit (I'm assuming English as the language here, 
of course). It is underlined in red, and ctrl-clicking on it brings up a list 
of suggestions. So the system recognises it as a misspelling, a word that it 
doesn't know.

Now try this in any test app:

NSRange range = [[NSSpellChecker sharedSpellChecker] 
checkSpellingOfString:@"accade" startingAt:0];
NSLog (@"NSStringFromRange(range));

range will be (NSNotFound,0).

I don't understand why, though. Why isn't NSSpellChecker returning this as a 
misspelling? Am I missing something obvious? Is there a better way to insert 
the spelling suggestions at the top of the menu?

Thanks and all the best,
Keith


  
___

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

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

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

This email sent to arch...@mail-archive.com


Re: NSSpellChecker and checkSpellingOfString problems

2009-12-04 Thread Keith Blount
Hi,

Sorry, I missed your e-mail yesterday and only just saw it.

> Can't you simply use something like
> NSMenu *theMenu = [super menuForEvent:theEvent];
> early in your code and let the system do the heavy lifting?

Unfortunately it's not as simple as that as the only items I need are the 
spelling items, and you never know how many there are. And as they use private 
methods, there's no reliable way to check which items you need to grab, or even 
which item will be the first below them across different operating systems.

Thanks for the suggestion, though.

All the best,
Keith


  
___

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

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

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

This email sent to arch...@mail-archive.com


Re: [iphone] Libxml2 with a wrapper to NSArray

2009-12-04 Thread Philip Vallone
Hi Thanks for the help. I did not receive any message from Sean, but your 
comments lead me in the right direction.

First I changed xmlData to:

NSData * xmlData = [NSData dataWithContentsOfFile: filePath]; 

Next I had a syntax error when declaring my NSArray and like you said it was 
pointing to an empty array:

NSArray* result = [NSArray arrayWithArray:PerformXMLXPathQuery(xmlData, 
@"//mynode")];

Final solution:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"manifest" 
ofType:@"xml"]; 
   NSData * xmlData = [NSData dataWithContentsOfFile: filePath];
   NSArray* result = [NSArray arrayWithArray:PerformXMLXPathQuery(xmlData, 
@"//mynode")];

As for your last point about learning C, I have picked up 2 books on the 
subject and have been learning.

Thanks again for the help

Phil


On Dec 3, 2009, at 10:34 PM, Fritz Anderson wrote:

> On 3 Dec 2009, at 5:40 PM, Philip Vallone wrote:
> 
>>  NSString *filePath = [[NSBundle mainBundle] pathForResource:@"manifest" 
>> ofType:@"xml"]; 
>>  NSData* xmlData = [filePath dataUsingEncoding:NSUTF8StringEncoding];
> 
> Separate from Sean's help, sending dataUsingEncoding: to an NSString gets you 
> an NSData that wraps the binary representation of the characters of the 
> string itself. You want something like
> 
>   NSData * xmlData = [NSData dataWithContentsOfFile: filePath];
> 
> Also:
>>  NSArray *resultNodes = [NSArray array];
> 
> This points the variable resultNodes at an empty NSArray, which you will not 
> be able to change.
> 
>> warning: implicit declaration of function 'PerformXPathQuery'
> 
> This indicates that you use of PerformXPathQuery was the first time the 
> compiler has ever seen that function. It is universal practice to declare 
> functions in advance, usually in a header (.h) file imported into the source 
> file. It helps the compiler generate correct code and warn you about 
> potential errors.
> 
> This last point is kind of basic to C. If you're not used to C, you shouldn't 
> be starting with Objective-C, Cocoa, and libxml. Take a couple of weeks, back 
> off, and learn C and its standard libraries first.
> 
>   — F
> 

___

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

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

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

This email sent to arch...@mail-archive.com


Re: How to get an italic font

2009-12-04 Thread Gerriet M. Denkmann

On 4 Dec 2009, at 14:44, mlist0...@gmail.com wrote:

> Is there some reason you can't use -[NSFontManager convertFont:toHaveTrait:] ?
No reason at all, except my ignorance of this method.


> It "returns a font whose traits are the same as those of the given font, 
> except that the traits are changed to include the single specified trait."
> 
> So something like:
> 
> NSFont* myFont = [your code here];
> NSFont* myItalicFont = [[NSFontManager sharedFontManager] convertFont:myFont 
> toHaveTrait:NSItalicFontMask];
> 
> _murat

This works perfectly. Thank you very much!


Kind regards,

Gerriet.

> 
> On Dec 3, 2009, at 11:15 PM, Gerriet M. Denkmann wrote:
> 
>> I want an italic font corresponding to an existing font.
>> 
>> I tried:
>> 
>>  NSFontDescriptor *fd1 = [ NSFontDescriptor fontDescriptorWithName: 
>> @"Times" size: textFontSize ];
>>  NSLog(@"%s text NSFontDescriptor %@",__FUNCTION__, fd1);
>>  // NSFontNameAttribute = Times;  NSFontSizeAttribute = 16;
>> 
>>  fontText = [ NSFont fontWithDescriptor: fd1 size: textFontSize ];
>>  NSLog(@"%s text NSFont %@",__FUNCTION__, fontText);
>>  //  "Times-Roman 16.00 pt. P [] (0x1190e0f90) fobj=0x1190e0590, 
>> spc=4.00"
>> 
>> So far so good.
>> 
>> Now I try to make the italic variant:
>>  NSFontSymbolicTraits symbolicTraits = NSFontItalicTrait;
>>  NSFontDescriptor *fdi = [ fd1 fontDescriptorWithSymbolicTraits: 
>> symbolicTraits ];
>>  NSLog(@"%s italic NSFontDescriptor %@",__FUNCTION__, fdi);
>>  // NSCTFontTraitsAttribute = { NSCTFontSymbolicTrait = 1; }; 
>> NSFontSizeAttribute = 16;
>> Note: NSFontNameAttribute has disappeared
>> The  documentation says: "Returns a new font descriptor that is the same as 
>> the receiver but with the specified symbolic traits taking precedence over 
>> the existing ones."
>> 
>>  italicText = [ NSFont fontWithDescriptor: fdi size: textFontSize ];
>>  NSLog(@"%s italic NSFont %@",__FUNCTION__, italicText);
>>  //  "LucidaGrande 16.00 pt. P [] (0x1190e0f90) fobj=0x10046adb0, 
>> spc=5.06"
>> 
>> This is comple nonsense: Lucida Grande is not italic and does not have an 
>> italic variant (only normal and bold).
>> 
>> I would have expected something like Times-Italic.
>> 
>> So: how to get an italic variant to a given font without hardcoding font 
>> names?

___

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

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

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

This email sent to arch...@mail-archive.com


Re: A hillegass challenge

2009-12-04 Thread Rob Keniger

On 04/12/2009, at 5:55 PM, Seth Willits wrote:

>> My question pertains to knowingly setting an object to NULL and then 
>> knowingly sending it a message as an acceptable technique.
> 
> As general answer: Yep. Happens all the time.


As Seth points out, this is perfectly normal. However, you should generally use 
"nil" instead of "NULL" for nil objects in Objective-C.

It doesn't matter from a technical point of view (they're both the same) but 
it's the accepted coding style.

--
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 arch...@mail-archive.com