Re: What rect does NSTextFieldCell use to draw its contents?

2012-12-14 Thread jonat...@mugginsoft.com

On 13 Dec 2012, at 23:17, Kyle Sluder  wrote:

> 
> Since I'm comparing the string-drawing methods to NSTextFieldCell
> drawing, according to this documentation there should be no difference.
> 
In my test case I compared the cells rendering with an NSTextField configured 
as a label.

@implementation MyTextFieldCell

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
NSStringDrawingOptions options = 0;
if (self.truncatesLastVisibleLine)
options |= NSStringDrawingTruncatesLastVisibleLine;
if (!self.usesSingleLineMode)
options |= NSStringDrawingUsesLineFragmentOrigin;

NSAttributedString *attString = [[NSAttributedString alloc] 
initWithString:self.stringValue];
[attString drawWithRect:[self titleRectForBounds:cellFrame] 
options:options];
}

@end

I tried the following uber simple implementation above and it doesn't produce 
the same rendering as a standard text cell.
The custom implementation is a couple of pixels offset to the left plus the 
font weight and kerning is slightly different.

So the implementation used by NSTextFieldCell obviously isn't the same as this.
The cell is free of course to offset the text frame as it sees fit prior to 
actual text rendering.
e.g.: when drawing complex cells with images etc it is necessary to introduce 
offsets between the rendered elements.

The docs for drawInteriorWithFrame:inView: say:

Text-type NSCell objects display their contents in a rectangle slightly inset 
from cellFrame using a global NSText object.

Is that offset accessible via the API or related to  titleRectForBounds:?

The docs for titleRectForBounds: say:

If the receiver is a text-type cell, this method resizes the drawing rectangle 
for the title (theRect) inward by a small offset to accommodate the cell 
border. If the receiver is not a text-type cell, the method does nothing.

But surely the cellFrame received by drawInteriorWithFrame:inView: has already 
accounted for the cell border, or is this another interior border?

So I think this might be an implementation guessing game.

If the rendering issue is comparative (i.e.: the custom render looks bad 
compared to the default in say a table view) then a solution might be to use 
the custom implementation everywhere.

Jonathan
___

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

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

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

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


Re: Bindings validation for NSMutableArray of NSMutableDictionary

2012-12-14 Thread Mike Abdullah
I'd strongly advise the OP it's better for them to create a custom class for 
their model objects, rather than go down this route of globally modifying 
NSMutableDictionary's API.

On 13 Dec 2012, at 22:18, jonat...@mugginsoft.com wrote:

> On 13 Dec 2012, at 11:54, jonat...@mugginsoft.com wrote:
> 
>> I bind an NSArray of NSMutableDictionary instances to an NSTableView and 
>> enable NSTableColumn editing..
>> 
>> How can I best implement KVO based validation when editing the view?
>> 
>> Subclassing NSArray controller is a no go as validateValue:forKeyPath:error 
>> is never called.
>> Subclassing the NSMutableDictionary model obviously isn't desirable.
>> 
>> I can refactor the NSMutableDictionary instances into custom objects and use 
>> model based validation if needed.
>> 
>> However, binding dictionaries into table views is often convenient so a 
>> working validation strategy would be useful.
>> 
>> Jonathan
> 
> The following category enables NSMutableDictionary KVC validation routing to 
> a delegate.
> 
> NSMutableDictionary *connection = [self selectedConnection];
> connection.validationDelegate = self;
> 
> The delegate then performs validation in:
> 
> - (BOOL)validateValue:(id *)ioValue forKey:(NSString *)key error:(NSError 
> **)outError sender:(NSMutableDictionary *)sender
> 
> See https://github.com/mugginsoft/NSMutableDictionary-KVCValidation
> 
> Simple refactoring would enable routing of KVC validation for any class.
> 
> Jonathan
> 
> 
> #import "NSMutableDictionary+KVCValidation.h"
> #import 
> 
> const char validationDelegateKey;
> 
> /*
> 
> MethodSwizzle()
> 
> ref: 
> http://www.mikeash.com/pyblog/friday-qa-2010-01-29-method-replacement-for-fun-and-profit.html
> 
> */
> void MethodSwizzle(Class klass, SEL origSEL, SEL overrideSEL)
> {
>Method origMethod = class_getInstanceMethod(klass, origSEL);
>Method overrideMethod = class_getInstanceMethod(klass, overrideSEL);
> 
>// try and add instance method with original selector that points to new 
> implementation
>if (class_addMethod(klass, origSEL, 
> method_getImplementation(overrideMethod), 
> method_getTypeEncoding(overrideMethod))) {
> 
>// add or replace method so that new selector points to original 
> method 
>class_replaceMethod(klass, overrideSEL, 
> method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
>} else {
> 
>// class already has an override method so just swap the 
> implementations.
>method_exchangeImplementations(origMethod, overrideMethod);
>}
> }
> 
> @implementation NSMutableDictionary (KVCValidation)
> 
> /*
> 
> + load
> 
> */
> + (void)load
> {
>MethodSwizzle(self, @selector(validateValue:forKey:error:), 
> @selector(swizzle_validateValue:forKey:error:));
> }
> 
> /*
> 
> - setValidationDelegate:
> 
> */
> - (void)setValidationDelegate:(id)validationDelegate
> {
>objc_setAssociatedObject(self, &validationDelegateKey, validationDelegate, 
> OBJC_ASSOCIATION_RETAIN);
> }
> 
> /*
> 
> - validationDelegate
> 
> */
> - (id)validationDelegate
> {
>return objc_getAssociatedObject(self, &validationDelegateKey);
> }
> 
> /*
> 
> - swizzle_validateValue:forKey:error:
> 
> */
> - (BOOL)swizzle_validateValue:(id *)ioValue forKey:(NSString *)key 
> error:(NSError **)outError
> {
>id validationDelegate = self.validationDelegate;
>SEL validationSelector = @selector(validateValue:forKey:error:sender:);
>BOOL isValid = NO;
> 
>if ([validationDelegate respondsToSelector:validationSelector]) {
>isValid = [validationDelegate validateValue:ioValue forKey:key 
> error:outError sender:self];
>} else {
>// remember, we swap IMPS at run time
>isValid = [self swizzle_validateValue:ioValue forKey:key 
> error:outError];
>}
> 
>return isValid;
> }
> @end
> 
> Jonathan
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: NSMutableData and Pinned Memory buffers..

2012-12-14 Thread Mike Abdullah
Arguably, you'd be better off subclassing NSData directly to add the mutation 
APIs that you actually need. That clears up any possible confusion about 
methods which might affect the length of the data.

On 14 Dec 2012, at 00:13, Robert Monaghan wrote:

> Thanks for the suggestion, Kevin!
> 
> I went ahead and created a really crude subclass of NSMutableData. It seems 
> to work for my situation.
> Attached is the code, for posterity. (I am sure I won't be the only one 
> working around this.)
> 
> Any suggestions to make this a bit more "Proper" are welcome.
> 
> bob.
> 
> //
> //  GT_NSMutableData.h
> //
> //  Created by Robert Monaghan on 12/13/12.
> //  Copyright (c) 2012 Glue Tools LLC. All rights reserved.
> //
> 
> #import 
> 
> @interface GT_NSMutableData : NSMutableData
> {
>   void *_gt_buffer;
>   NSUInteger _gt_length;
>   BOOL _gt_freeWhenDone;
> }
> @property (readwrite) NSUInteger length;
> @end
> 
> //
> //  GT_NSMutableData.m
> //
> //  Created by Robert Monaghan on 12/13/12.
> //  Copyright (c) 2012 Glue Tools LLC. All rights reserved.
> //
> 
> #import "GT_NSMutableData.h"
> 
> @implementation GT_NSMutableData
> + (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length 
> freeWhenDone:(BOOL)b
> {
>   return [[[GT_NSMutableData alloc] initWithBytesNoCopy:bytes 
> length:length freeWhenDone:b] autorelease];
> }
> 
> - (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)length 
> freeWhenDone:(BOOL)b
> {
>self = [super init];
>if (self) {
>_gt_buffer = bytes;
>   _gt_length = length;
>   _gt_freeWhenDone = b;
>}
>return self;
> }
> 
> - (void)dealloc
> {
>if (_gt_freeWhenDone)
>   free(_gt_buffer);
>   
>[super dealloc];
> }
> 
> - (void)increaseLengthBy:(NSUInteger)extraLength
> {
> }
> 
> - (void)setLength:(NSUInteger)length
> {
> }
> 
> - (NSUInteger) length
> {
>   return _gt_length;
> }
> 
> - (const void *)bytes
> {
>   return _gt_buffer;
> }
> 
> - (void *)mutableBytes
> {
>   return _gt_buffer;
> }
> 
> - (void)replaceBytesInRange:(NSRange)range withBytes:(const void *)bytes
> {
> }
> 
> - (void)replaceBytesInRange:(NSRange)range withBytes:(const void 
> *)replacementBytes length:(NSUInteger)replacementLength
> {
> }
> 
> - (void)resetBytesInRange:(NSRange)range
> {
> }
> 
> - (void)setData:(NSData *)data
> {
>   _gt_buffer = (void *)[data bytes];
> }
> 
> @end
> 
> 
> On Dec 13, 2012, at 3:22 PM, Kevin Perry  wrote:
> 
>> NSMutableData currently ignores (and always has, to my knowledge) the 
>> no-copy "hint" and always copies the bytes into an internal buffer in case 
>> something tries to change the length of the NSMutableData.
>> 
>> It would not be too difficult to make a subclass of NSMutableData that 
>> doesn't copy and throws an exception when something tries to change the 
>> length. That would violate the Liskov substitution principle though, so at 
>> the very least, you want to prevent any code that doesn't understand the 
>> fixed-length restriction from getting ahold of one of these objects.
>> 
>> [kevin perry];
>> 
>> On Dec 13, 2012, at 2:28 PM, Robert Monaghan  wrote:
>> 
>>> Hi Everyone,
>>> 
>>> I have just run head long into an issue with NSMutableData and existing 
>>> buffers.
>>> I have the following code:
>>> 
>>> 
>>> UInt8 *sourcebytes = [clImgEngine srcBuffer];
>>> [self setData:[NSMutableData 
>>> dataWithBytesNoCopy:sourcebytes length:[clImgEngine inRangeByteCount] 
>>> freeWhenDone:NO]];
>>> UInt8 *resultBytes = [[self data] mutableBytes];
>>> 
>>> The source is a pinned memory buffer from OpenCL. What I want to do, is to 
>>> pass this buffer inside a NSMutableData wrapper and have another object for 
>>> some work.
>>> Seems simple enough, except that NSMutableData changes the memory buffer in 
>>> the background.
>>> 
>>> "sourcebytes" starts with an address such as: 0x00012361b000
>>> and "resultBytes" returns 0x000136fe2000
>>> 
>>> Naturally, my work object doesn't see any data from "sourcebytes", as 
>>> NSMutableData has moved the buffer.
>>> I thought that freeWhenDone:NO prevented ownership of the buffer..
>>> 
>>> Can anyone suggest a way to prevent this from happening? I need the buffer 
>>> to stay "pinned".
>>> 
>>> Thanks in advance!
>>> 
>>> bob.
>>> 
>>> ___
>>> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>> 
>>> Please do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>> 
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/cocoa-dev/kperry%40apple.com
>>> 
>>> This email sent to kpe...@apple.com
>> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the mo

Re: Bindings validation for NSMutableArray of NSMutableDictionary

2012-12-14 Thread jonat...@mugginsoft.com

On 14 Dec 2012, at 11:13, Mike Abdullah  wrote:

> I'd strongly advise the OP it's better for them to create a custom class for 
> their model objects, rather than go down this route of globally modifying 
> NSMutableDictionary's API.

In general I would strongly advise this too, which effectively means don't use 
editable bindings with NSMutableDictionary.

However, it is a practical solution to an implementation problem.

Jonathan
___

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

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

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

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


Re: What rect does NSTextFieldCell use to draw its contents?

2012-12-14 Thread Kyle Sluder
On Dec 14, 2012, at 2:42 AM, "jonat...@mugginsoft.com" 
 wrote:
> 
> On 13 Dec 2012, at 23:17, Kyle Sluder  wrote:
> 
>> 
>> Since I'm comparing the string-drawing methods to NSTextFieldCell
>> drawing, according to this documentation there should be no difference.
> In my test case I compared the cells rendering with an NSTextField configured 
> as a label.
> 
> @implementation MyTextFieldCell
> 
> - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
>NSStringDrawingOptions options = 0;
>if (self.truncatesLastVisibleLine)
>options |= NSStringDrawingTruncatesLastVisibleLine;
>if (!self.usesSingleLineMode)
>options |= NSStringDrawingUsesLineFragmentOrigin;
> 
>NSAttributedString *attString = [[NSAttributedString alloc] 
> initWithString:self.stringValue];
>[attString drawWithRect:[self titleRectForBounds:cellFrame] 
> options:options];
> }
> 
> @end
> 
> I tried the following uber simple implementation above and it doesn't produce 
> the same rendering as a standard text cell.
> The custom implementation is a couple of pixels offset to the left plus the 
> font weight and kerning is slightly different.

Well, you're not using the same attributes, so of course it's not going to be 
the same. I went so far as to get the exact attributes the text field uses by 
calling -_textAttributes, in the hope that it was a line fragment padding 
issue. Still no dice.

> 
> So the implementation used by NSTextFieldCell obviously isn't the same as 
> this.
> The cell is free of course to offset the text frame as it sees fit prior to 
> actual text rendering.
> e.g.: when drawing complex cells with images etc it is necessary to introduce 
> offsets between the rendered elements.

Yes, that's the offset frame I'm trying to figure out.

> 
> The docs for drawInteriorWithFrame:inView: say:
> 
> Text-type NSCell objects display their contents in a rectangle slightly inset 
> from cellFrame using a global NSText object.
> 
> Is that offset accessible via the API or related to  titleRectForBounds:?

According to my understanding of the API, -titleRectForBounds: should be 
returning this rect, but clearly NSTextFieldCell is insetting this rect further.

But NSTextFieldCell does its own drawing anyway. It doesn't call -[NSCell 
drawInteriorWithFrame:inView:], so it doesn't go through the "text-type NSCell" 
drawing path.

> 
> The docs for titleRectForBounds: say:
> 
> If the receiver is a text-type cell, this method resizes the drawing 
> rectangle for the title (theRect) inward by a small offset to accommodate the 
> cell border. If the receiver is not a text-type cell, the method does nothing.
> 
> But surely the cellFrame received by drawInteriorWithFrame:inView: has 
> already accounted for the cell border, or is this another interior border?

My text field is borderless. I can confirm that -drawInteriorWithFrame receives 
the same rect as -drawWithFrame:inView:.

> 
> So I think this might be an implementation guessing game.

I have a disassembler; I can do better than guess. :) I was just hoping there 
was some aspect of the documentation I had overlooked.

> 
> If the rendering issue is comparative (i.e.: the custom render looks bad 
> compared to the default in say a table view) then a solution might be to use 
> the custom implementation everywhere.

Thankfully appearance isn't an issue; my custom text field cell will be used 
for all instances in the same area. My chief concern is what NSTextField will 
return for -layoutRectForFrame: and how it will differ from my actual drawing 
metrics, which is why I'm trying to replicate NSTextFieldCell's drawing 
precisely.

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Build script

2012-12-14 Thread Rui Pacheco
Hello,

I have a couple of scripts I use to build my projects and automate releases. 
I've started with Bash and am currently finishing a Python version of it. I 
find Python easier to read and maintain than Bash.

What do you use to automate your releases?

--
Rui Pacheco



___

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

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

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

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


NSWorkspace recycleURLs:completionHandler error -5000 (afpAccessDenied)

2012-12-14 Thread Jon Gary
I have a sandboxed app that creates a file in a folder within the app's sandbox 
container. When the app is done with the file, it is moved to the trash using 
recycleURLs:completionHandler. A few of our users are reporting the "you do not 
have permision to move the file to the trash." I've checked the permissions on 
the file itself and the user has read and write accces. We've had them run a 
shell command to make sure they have write access to their trash directory. 
None of this helps. I'm stumped.
 
I've asked the user if they are using a networked home directory, but they say 
no (I'm not sure they understood the question).
 
Any clues?

--
Jon Gary / Object Orienteer / Ambrosia Software, Inc. -- 
http://www.AmbrosiaSW.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


CALayer UIImage rendered on top of content instead of below

2012-12-14 Thread Markus Spoettl

Hi,

  I have custom UIView with multiple layers, all custom drawn via delegate. In 
one layer, I draw an image and on top of that image, I draw bezier paths and 
rects. Or so I try. For some reason the image is rendered ABOVE what I draw OVER 
it later.


So basically I have this (this is the actual code I reduced it to):

[img drawInRect:imgRect blendMode:kCGBlendModeNormal alpha:1.0];

followed by

[[UIColor redColor] setFill];
UIRectFill(imgRect);

I would expect to see a red rectangle, I get the image. Why? Would someone set 
me straight, I feel I'm missing something basic.


Regards
Markus
--
__
Markus Spoettl
___

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

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

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

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


Correct way to make mutable and immutable objects?

2012-12-14 Thread Graham Cox

Hi all,

I'm having trouble getting this to work how I think it should, i must be 
missing something.

I have an abstract base class A and a mutable subclass AM. The class A owns a 
list of subsidiary objects but only the class AM has the methods for adding and 
removing these , which is what 'mutable' means for this class.

There are a series of concrete subclasses B, C, D, etc which all set up the 
subsidiary objects in various configurations when they are initialized, but 
once done, the clients of these objects have no business mutating them so they 
need to be returned as the immutable variant. However, in order to work during 
setup they are in fact subclasses of AM. Is there a way to return them as if 
they were subclasses of A, so that the existence of the mutating methods is 
hidden from the client code?

It only needs to go as far as flagging a compile warning if the client attempts 
to use a mutating method, it doesn't need to go as far as return NO from 
-respondsToSelector: for these methods, since in reality they are in fact AM 
subclasses. Is it just a case of putting these methods into a category that is 
included by B, C, D but not by client code, so that such methods don't exist in 
the public interface? What's the usual solution?

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: CALayer UIImage rendered on top of content instead of below

2012-12-14 Thread David Duncan
On Dec 14, 2012, at 3:07 PM, Markus Spoettl  wrote:

>  I have custom UIView with multiple layers, all custom drawn via delegate. In 
> one layer, I draw an image and on top of that image, I draw bezier paths and 
> rects. Or so I try. For some reason the image is rendered ABOVE what I draw 
> OVER it later.
> 
> So basically I have this (this is the actual code I reduced it to):
> 
> [img drawInRect:imgRect blendMode:kCGBlendModeNormal alpha:1.0];
> 
> followed by
> 
> [[UIColor redColor] setFill];
> UIRectFill(imgRect);
> 
> I would expect to see a red rectangle, I get the image. Why? Would someone 
> set me straight, I feel I'm missing something basic.


Unfortunately I think you've removed too much context here. Since you say you 
are doing this in your own layers, it would be useful to know which class is 
acting as the delegate, and what the complete -drawLayer:inContext: method 
looks like (primarily because you are using the UIKit methods that expect an 
implicit context).
--
David Duncan


___

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

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

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

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


Re: CALayer UIImage rendered on top of content instead of below

2012-12-14 Thread Kyle Sluder
On Dec 14, 2012, at 3:07 PM, Markus Spoettl  wrote:

> Hi,
> 
>  I have custom UIView with multiple layers, all custom drawn via delegate. In 
> one layer, I draw an image and on top of that image, I draw bezier paths and 
> rects. Or so I try. For some reason the image is rendered ABOVE what I draw 
> OVER it later.
> 
> So basically I have this (this is the actual code I reduced it to):
> 
> [img drawInRect:imgRect blendMode:kCGBlendModeNormal alpha:1.0];
> 
> followed by
> 
> [[UIColor redColor] setFill];
> UIRectFill(imgRect);
> 
> I would expect to see a red rectangle, I get the image. Why? Would someone 
> set me straight, I feel I'm missing something basic.

So if you create a new project, subclass UIView, and implement 
-drawLayer:inContext: like this, you get bad drawing?

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: NSWorkspace recycleURLs:completionHandler error -5000 (afpAccessDenied)

2012-12-14 Thread Mike Abdullah

On 14 Dec 2012, at 21:26, Jon Gary wrote:

> I have a sandboxed app that creates a file in a folder within the app's 
> sandbox container. When the app is done with the file, it is moved to the 
> trash using recycleURLs:completionHandler. A few of our users are reporting 
> the "you do not have permision to move the file to the trash." I've checked 
> the permissions on the file itself and the user has read and write accces. 
> We've had them run a shell command to make sure they have write access to 
> their trash directory. None of this helps. I'm stumped.
> 
> I've asked the user if they are using a networked home directory, but they 
> say no (I'm not sure they understood the question).
> 
> Any clues?

When you say inside the app's sandbox container, where specifically are we 
talking?


___

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

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

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

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


Re: blocks and id

2012-12-14 Thread Uli Kusterer
On 12.12.2012, at 10:03, Andreas Grosam  wrote:
> How can I check at runtime whether an object (id) is actually a block, and 
> not another kind of object?

 Not a good idea. What are you really trying to do? Here's a few common cases 
and suggestions on how to do it better, and why:

1) Serializing objects. Generally, the object (or a category on it if it's an 
object you didn't create) should implement a method that knows how to 
serialize/unserialize it, like -initWithCoder: and -encodeWithCoder:. This 
allows any class to be added, and allows for overriding a the method in a 
subclass. If you use -isKindOfClass:

2) Implementing special behaviour on some objects, while falling back on some 
default behaviour for all others. Call respondsToSelector: in this case. It has 
the advantage that it doesn't break duck typing. Even if you get an NSProxy for 
the actual object, it will respond to the selector and still work as expected. 

Asking for an object's class using isKindOfClass: is a definite code smell.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.masters-of-the-void.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: blocks and id

2012-12-14 Thread Uli Kusterer

On 15.12.2012, at 01:38, Uli Kusterer  wrote:

> On 12.12.2012, at 10:03, Andreas Grosam  wrote:
>> How can I check at runtime whether an object (id) is actually a block, and 
>> not another kind of object?
> 
> Not a good idea. What are you really trying to do? Here's a few common cases 
> and suggestions on how to do it better, and why:
> 
> 1) Serializing objects. Generally, the object (or a category on it if it's an 
> object you didn't create) should implement a method that knows how to 
> serialize/unserialize it, like -initWithCoder: and -encodeWithCoder:. This 
> allows any class to be added, and allows for overriding a the method in a 
> subclass. If you use -isKindOfClass:

Drat, accidentally hit 'send'. That should be If you use -isKindOfClass:, all 
subclasses will also return YES, and that one method will have to know about 
all the different types (from different layers of your app that might be 
serialized), and you'll have one file with thousands of dependencies, that get 
dragged into any other app that wants to be able to use the same serialization 
mechanism.

> 2) Implementing special behaviour on some objects, while falling back on some 
> default behaviour for all others. Call respondsToSelector: in this case. It 
> has the advantage that it doesn't break duck typing. Even if you get an 
> NSProxy for the actual object, it will respond to the selector and still work 
> as expected. 

 Same for any other kind of method forwarding or dynamic method implementation 
like Key-Value-Observing.

> Asking for an object's class using isKindOfClass: is a definite code smell.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de




___

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

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

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

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


Re: Build script

2012-12-14 Thread Uli Kusterer
On 14.12.2012, at 20:50, Rui Pacheco  wrote:
> I have a couple of scripts I use to build my projects and automate releases. 
> I've started with Bash and am currently finishing a Python version of it. I 
> find Python easier to read and maintain than Bash.
> 
> What do you use to automate your releases?


 Old stuff is bash (or csh?), new stuff is Ruby. At home for my hobby stuff I 
usually use PHP because it's at least a programming language, while bash is 
pretty much just text search-and-replace with side effects (most of these are 
older and already existing, so they would have ended up bash otherwise, not 
Ruby).

 The scripts do things like fix up resource issues that Xcode sometimes causes, 
unzip built versions of frameworks that we check in as binaries because access 
to the source is restricted for licensing reasons etc. I also had scripts that 
use the FTP or curl command line tools to upload.

 We even have bash scripts in .command files that you can just double-click to 
get a certain kind of build in a reliable way.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de




___

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

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

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

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


Re: How to capture a video stream

2012-12-14 Thread gary . gardner
>> On 11 Dec 2012, at 05:33, gary.gard...@brokensoftware.com wrote:
>>>
>>> I need further assistance.  I select the capture device, but after I
>>> execute run, I get the following:
>>>
>>> Invalid memory access of location 0x0 rip=0x7fff933e3598
>>> 942 Segmentation fault: 11
>>>
>>> I am following the AVVideoWall example code.  However, I am not
>>> outputting
>>> to the desktop and layers.
>>>
>>> Can someone point me in the right direction on solving this issue?
>>>
>> The stack trace would certainly help. Can you post it?
>>
>> Jonathan
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/gary.gardner%40brokensoftware.com
>>
>> This email sent to gary.gard...@brokensoftware.com
>>
>
Jonathan,

Any thoughts on this yet?
___

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

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

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

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


Scroll Lock button press event (PC keyboard)

2012-12-14 Thread Nick
Hello
I need to intercept a scroll lock key event (that can be found on most of
 PC keyboards).
It seems that AppKit framework does not pass any NSEvent's to the
application when this button is pressed.
Neither works addGlobalMonitorForEventsMatchingMask (access for assistive
devices is enabled). I tried the mask NSFlagsChangedMask|NSKeyPressedMask -
the block gets invoked when any button is pressed, except the scroll lock.

Is it possible at all to get a notification in my app when scroll lock is
pressed? Using IOKit maybe?

I need to monitor this event system-wide (i.e, not only when my application
window is the key window).

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Correct way to make mutable and immutable objects?

2012-12-14 Thread Quincey Morris
On Dec 14, 2012, at 15:25 , Graham Cox  wrote:

> I have an abstract base class A and a mutable subclass AM. The class A owns a 
> list of subsidiary objects but only the class AM has the methods for adding 
> and removing these , which is what 'mutable' means for this class.
> 
> There are a series of concrete subclasses B, C, D, etc which all set up the 
> subsidiary objects in various configurations when they are initialized, but 
> once done, the clients of these objects have no business mutating them so 
> they need to be returned as the immutable variant. However, in order to work 
> during setup they are in fact subclasses of AM. Is there a way to return them 
> as if they were subclasses of A, so that the existence of the mutating 
> methods is hidden from the client code?

Here are some possibilities:

1. Declare certain ivars @protected, allowing the subclass initializers to 
manipulate the subsidiary object collections directly.

2. Use a class-hierarchy-private initializer that passes the subsidiary object 
list up from the subclass to the base class, or a class-hierarchy-private 
method that replaces the default list, called during the subclass initializer.

3. Have each subclass initializer return an immutable copy of a mutable 
temporary object used for the initial part of the initialization.

4. Implement immutability as an internal class property, like NSArray etc. In 
that case, the class can be mutable for the duration of the initializer, then 
forced to be un-mutable. (The setters go in the base class, but they all start 
by explicitly testing the internal mutability property.)

Personally, I prefer #4, because it means the class implementation doesn't have 
to fight with the details of the class public interface. It just takes a bit 
more (very dull) code.


___

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

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

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

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


Re: Scroll Lock button press event (PC keyboard)

2012-12-14 Thread Nick
No, nothing lights up. In fact, the only LED on my PC keyboard that can
light up in Mac OS from keypresses is the Caps Lock.
I am wondering if I could use IOKit to get Scroll lock keypress event,
though?.


2012/12/15 Kyle Sluder 

> On Dec 14, 2012, at 5:55 PM, Nick  wrote:
>
> > Hello
> > I need to intercept a scroll lock key event (that can be found on most of
> > PC keyboards).
> > It seems that AppKit framework does not pass any NSEvent's to the
> > application when this button is pressed.
> > Neither works addGlobalMonitorForEventsMatchingMask (access for assistive
> > devices is enabled). I tried the mask
> NSFlagsChangedMask|NSKeyPressedMask -
> > the block gets invoked when any button is pressed, except the scroll
> lock.
> >
> > Is it possible at all to get a notification in my app when scroll lock is
> > pressed? Using IOKit maybe?
>
> Open the Keyboard Viewer (you might need to turn on the Input Languages
> menu extra in System Preferences). Does anything light up when you press
> the Scroll Lock key?
>
> If yes, use that key's virtual key code. If not, you're sunk.
>
> --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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Simple Auto-Layout problem

2012-12-14 Thread Eric Gorr
Well, I thought this was a simple auto-layout problem. As it turns out, it is a 
bug. I have filed a bug report -  rdar://12888108

However, there is a workaround for this bug. The NSView which is a parent to 
the NSButton needs to be a subclass of NSView with at least a -drawRect: method.


On Dec 10, 2012, at 9:27 PM, Eric Gorr  wrote:

> Well, at least it looks like it should be a simple one. I have a sample 
> project at:
> 
> http://ericgorr.net/cocoadev/autolayout01.zip
> 
> If you run the app and resize the window to be it's smallest and then larger, 
> the button will not be drawn correctly, if at all. If one makes the window 
> bigger fast enough, at least part of the button will redraw correctly. I have 
> confirmed that the frame and bounds of the button remain unchanged.
> 
> If I disable auto-layout, the button will always draw correctly.
> 
> Does anyone have a good explanation of what is going on?
> 
> Thank you,
> Eric
> 


___

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

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

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

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