Re: Notification of autocomplete

2011-08-08 Thread Kyle Sluder
On Sun, Aug 7, 2011 at 11:40 PM, Joshua Garnham
 wrote:
>
> Is there some notification that is posted or some other way to tell when in a 
> NSTextView or any editable element that something has been autocorrected?

-textView:didCheckTextInRange:types:options:results:orthography:wordCount:

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSTextViewDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40008628-CH1-SW25

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


Re: CFURLWriteDataAndPropertiesToResource as root?

2011-08-08 Thread Eli Bach

On Aug 7, 2011, at 10:07 PM, Stephen Blinkhorn wrote:

> It's a validation file containing registration details. My product is an 
> AudioUnit plugin so there's no App Store potential but I'd prefer to keep 
> things clean just in case.
> 
> I don't care where I write the file much (previously I wrote it to 
> "/Library/Preferences") but even the hard drive root path is off limits. 
> Other suggestions include writing data into the keychain but this is just a 
> Lion compatibility fix and I'm not sure how keychain access from within an AU 
> would work out in practice.
> 
> I register the whole machine rather than individual users. Any other 
> suggestions as to where to write it?
> Stephen

Some apps, including iTunes, using /Users/Shared/ for DRM.  It may still be 
world-writable in Lion [which I can't confirm as I haven't switched yet...come 
on 10.7.2...].

Eli

___

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

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

2011-08-08 Thread vincent habchi
> Some apps, including iTunes, using /Users/Shared/ for DRM.  It may still be 
> world-writable in Lion [which I can't confirm as I haven't switched 
> yet...come on 10.7.2...].

I can confirm /Users/Shared is world writable on 10.7; besides, it has the 
sticky (8) bit set, just like /tmp.

Vincent

___

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

Please do not post admin requests or moderator comments to the list.
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: Notification of autocomplete (in any app)

2011-08-08 Thread Joshua Garnham
 Thanks, that's just what I was looking for. I am now able to know exactly when 
autocorrect has taken place in the NSTextView in my app. However (if you don't 
mind me extending my question), what if I wanted to know when this happens in 
any NSTextView in the active app whether it's my app, TextEdit or Safari? 
Similar to the app here (http://pilotmoon.com/popclip/). 

I'm not sure how exactly to go about this and the only thing I have thought of 
so far is becoming a service but I'm not sure it it's the right way to go about 
it and even so where I'd go from there.

Thanks again.

Josh 


On Monday, 8 August 2011 at 08:02, Kyle Sluder wrote:

> On Sun, Aug 7, 2011 at 11:40 PM, Joshua Garnham
> mailto:joshua.garn...@yahoo.co.uk)> wrote:
> > 
> > Is there some notification that is posted or some other way to tell when in 
> > a NSTextView or any editable element that something has been autocorrected?
> 
> -textView:didCheckTextInRange:types:options:results:orthography:wordCount:
> 
> http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSTextViewDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40008628-CH1-SW25
> 
> --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


Coordinate system in CAOpenGLLayer

2011-08-08 Thread Graham Cox
I'm looking at using CAOpenGLLayer to boost drawing performance. I'm a total 
novice at OpenGL.

Looking at the 'CALayerEssentials' sample code as a starting point, it has the 
following code:

-(void)drawInCGLContext:(CGLContextObj)glContext 
pixelFormat:(CGLPixelFormatObj)pixelFormat 
forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp 
*)timeStamp
{
// Set the current context to the one given to us.
CGLSetCurrentContext(glContext);

// We're just going to draw a single red quad spinning around based on 
the current time. Nothing particularly fancy.
GLfloat rotate = timeInterval * 60.0; // 60 degrees per second!
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glRotatef(rotate, 0.0, 0.0, 1.0);
glBegin(GL_QUADS);
glColor3f(1.0, 0.0, 0.0);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5,  0.5);
glVertex2f( 0.5,  0.5);
glVertex2f( 0.5, -0.5);
glEnd();
glPopMatrix();

// Call super to finalize the drawing. By default all it does is call 
glFlush().
[super drawInCGLContext:glContext pixelFormat:pixelFormat 
forLayerTime:timeInterval displayTime:timeStamp];
}


What I find a bit odd here is that the coordinate values for the glVertex calls 
are not related to the layer's actual bounds, but to some notional coordinate 
system stretching from -1 to +1 in each dimension. If the layer is resized, the 
'square' resulting stretches in proportion.

I didn't expect this, though perhaps it's normal for OpenGL, or at least 
CAOpenGLLayer. There's virtually nothing in the documentation about this layer 
or how it's set up, so I'm having a hard time understanding how I'm supposed to 
go about calculating the coordinates I need.

Can someone point me in the direction of any documentation that could help 
here, or at least confirm my observations about coordinates being relative to a 
+/- 1 virtual space?

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


Core Data : User missing inverse relationship despite model settings

2011-08-08 Thread Jerry Krinock
I received reports of identical Core Data validation errors from two users in 
the last week, which I cannot reproduce.  It involves these relationships, 
which are inverses of one another:

Bar Foo
foo <<> bars 

In both directions, the Delete Rule is "Nullify", and for the to-many relation, 
Min Count and Max Count are "none".  Bar's 'foo' is optional.  Foo's bars are 
not optional, although that does not seems to be the problem since all of the 
errant Foo objects in the reports seem to have bars.

The reports indicate (rather strangely, but I'm watching my word count here) 
that the problem is "Dangling reference to an invalid object".  Searching list 
archives tells me that this has been due to setting a relationship in 
-awakeFromFetch, which is illegal.  But I checked my project carefully and I'm 
not doing that.

However, in the error reports, I see that only one of the foo:bar relationships 
of the Foo objects tagged as NSValidationErrorObject are fulfilled:  The Foo's 
'bar' contains several Bar objects, but these Bar objects' 'foo' is nil.  I 
think that's the cause of the validation error – Core Data expects pairs of 
inverse relationships with Delete Rules both set to Nullify to always be either 
point to one another or both be nil.

Indeed, I cannot reproduce this 1/2 relationship in debugging…

• First, I try to do it by only creating one half.  When my app creates a Foo, 
it adds a couple of Bar objects immediately.  When I do that in debugging, Core 
Data immediately fulfills the inverse, so that the Bar objects now have a foo.  
So I have a two relationships.

• Then, I try to do it by deleting one half.  I grab a Bar which has a 'foo', 
and set send it setFoo:nil.  Core Data immediately removes this Bar object from 
the 'bars' set of its former Foo object.  So I have no relationships.

Summarizing, the paradox is that there I cannot, in code, create a 1/2 
relationship, apparently because of the data model settings.  But it happens 
occasionally in the wild.  How?

Thanks,

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


Re: Coordinate system in CAOpenGLLayer

2011-08-08 Thread Thomas Davie
You're right – the vertices are here specified in OpenGL "clip space" – a 
coordinate system stretching from -1 to 1 on all 3 axes.  If you want to 
specify points in a different coordinate space, it's your responsibility to 
make sure that they end up in clip space, by transforming them appropriately.  
In old world GL (as you have there) this is done through the fixed function 
transform:

vertex in model space -- * modelview matrix -> vertex in world space -- * 
projection matrix -> vertex in clip space -- divide x,y,z by w -> vertex in 
normalised device space -- viewport transform -> vertex in pixel space

I would however *highly* recommend not using old world GL.  It will make your 
later transition to OpenGL 3.2 core much much harder, as most of the functions 
here (glMatrixMode, glPushMatrix, glRotate, glBegin, glColor, glVertex, glEnd, 
glPopMatrix, and many others) are no longer present.

To get an idea of how to get started with modern OpenGL, take a look at 
https://github.com/beelsebob/Cocoa-GL-Tutorial and 
https://github.com/beelsebob/Cocoa-GL-Tutorial-2.  These are still written in 
OpenGL 2.1, but in a way that the port to 3.2 when you come to it is trivially 
easy.

Thanks

Tom Davie

if (*ra4 != 0xffc78948) { return false; }

On 8 Aug 2011, at 08:35, Graham Cox wrote:

> I'm looking at using CAOpenGLLayer to boost drawing performance. I'm a total 
> novice at OpenGL.
> 
> Looking at the 'CALayerEssentials' sample code as a starting point, it has 
> the following code:
> 
> -(void)drawInCGLContext:(CGLContextObj)glContext 
> pixelFormat:(CGLPixelFormatObj)pixelFormat 
> forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp 
> *)timeStamp
> {
>   // Set the current context to the one given to us.
>   CGLSetCurrentContext(glContext);
> 
>   // We're just going to draw a single red quad spinning around based on 
> the current time. Nothing particularly fancy.
>   GLfloat rotate = timeInterval * 60.0; // 60 degrees per second!
>   glClear(GL_COLOR_BUFFER_BIT);
>   glMatrixMode(GL_MODELVIEW);
>   glPushMatrix();
>   glRotatef(rotate, 0.0, 0.0, 1.0);
>   glBegin(GL_QUADS);
>   glColor3f(1.0, 0.0, 0.0);
>   glVertex2f(-0.5, -0.5);
>   glVertex2f(-0.5,  0.5);
>   glVertex2f( 0.5,  0.5);
>   glVertex2f( 0.5, -0.5);
>   glEnd();
>   glPopMatrix();
>   
>   // Call super to finalize the drawing. By default all it does is call 
> glFlush().
>   [super drawInCGLContext:glContext pixelFormat:pixelFormat 
> forLayerTime:timeInterval displayTime:timeStamp];
> }
> 
> 
> What I find a bit odd here is that the coordinate values for the glVertex 
> calls are not related to the layer's actual bounds, but to some notional 
> coordinate system stretching from -1 to +1 in each dimension. If the layer is 
> resized, the 'square' resulting stretches in proportion.
> 
> I didn't expect this, though perhaps it's normal for OpenGL, or at least 
> CAOpenGLLayer. There's virtually nothing in the documentation about this 
> layer or how it's set up, so I'm having a hard time understanding how I'm 
> supposed to go about calculating the coordinates I need.
> 
> Can someone point me in the direction of any documentation that could help 
> here, or at least confirm my observations about coordinates being relative to 
> a +/- 1 virtual space?
> 
> --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/tom.davie%40gmail.com
> 
> This email sent to tom.da...@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: resizing window containing NSView with CALayer

2011-08-08 Thread julius

On 7 Aug 2011, at 21:30, Kyle Sluder wrote:

> On Sun, Aug 7, 2011 at 1:05 PM, julius  wrote:
>> It is not a problem with the layers.
>> I get exactly the same behaviour if I leave out all the layer stuff and 
>> instead code the following in the view
> 
> Meaning, you still call -setLayer: and -setWantsLayer:, but don't do
> anything else with the layers?
> 
> Or have you removed the layer code from
> -applicationDidFinishLaunching: entirely?
> 
> --Kyle Sluder
Kyle hi
I've removed everything.
The program is as follows

//  LayersInViewAppDelegate.h
#import 
@class MyView;
@interface LayersInViewAppDelegate : NSObject  {
NSWindow *window;
IBOutlet MyView * myViewObj;
}
@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet MyView * myViewObj;
@end

//  LayersInViewAppDelegate.m
#import "LayersInViewAppDelegate.h"
#import "MyView.h"

@implementation LayersInViewAppDelegate
@synthesize window;
@synthesize myViewObj;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
}
@end

//  MyView.h
#import 
@interface MyView : NSView {
}
@end

//  MyView.m
#import "MyView.h"
@implementation MyView

- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
}
return self;
}

- (void)drawRect:(NSRect)dirtyRect {
[[NSColor blackColor]set];
[NSBezierPath fillRect:[self bounds]];
} // end drawRect
@end

I've also on occasion made the view a delegate of the window and observed the 
values of the view rect and bounds as the window resizes but the values give no 
clue to what might be happening.
Julius


http://juliuspaintings.co.uk



___

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

Please do not post admin requests or moderator comments to the list.
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: Asynchronous downloading and parsing of XML

2011-08-08 Thread Andreas Grosam

On Aug 7, 2011, at 1:47 PM, Mikkel Islay wrote:

> Thanks for sharing with the list.
> ... Aren't you in effect throwing away the benefits of asynchronous loading?

No. Asynchronous routines can be implemented above a blocking interface. 
Blocking and asynchronous interfaces work well together, and you may not even 
notice the existence of a blocking interface since it is working under the hood 
as an implementation detail.

For instance the parser *could* (we don't know) be implemented as a "recursive 
decent" parser. This kind of parser will effectively require that the parsing 
routine blocks, when there is no further input available, since the state of 
the parser will be in its call stack. So you can't just stop and exit the parse 
function in the middle of a stream, and then continue with a newly invoked 
method when more data is available. 

The parser would just dispatch its events on the main thread where the delegate 
can handle them. So, from the view point of the delegate, it looks like an 
asynchronous interface.


Andreas


> The NSInputstream can block, and NSXMLParser presumably will. You will also 
> have to deal with events in several places, and make sure errors are 
> propagated up and down the stream.
> 
> Mikkel
> 

___

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

Please do not post admin requests or moderator comments to the list.
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: resizing window containing NSView with CALayer

2011-08-08 Thread julius

On 8 Aug 2011, at 01:46, Graham Cox wrote:

> 
> On 08/08/2011, at 5:52 AM, julius wrote:
> 
>> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
> 
> 
>  I didn't notice first time through that this is where your code resides 
> (sometimes the most obvious errors pass by when you're looking out for a more 
> subtle error). It's certainly wrong to put it there. A view will typically 
> initialise its layer as part of its own initialisation, i.e. the layer set up 
> should be done in the view's -initWithFrame: method.
I've done as you suggested.
Putting it in initWithRect resulted in no drawing showing up in the window.
I then put it in awakeFromNib and it drew ok but the problem remained as before.
I also did a variant of that by putting the root layer initialisation in the 
initWithRect and the assignment of colour to the layer background in 
awakeFromNib but that did not display anything either. (I only started looking 
at layers this Friday last so am a bit at sea with this technology).

So the program currently looks as follows.
There's nothing in the app delegate except a IBOutlet to the view.
and the view looks like this

//  MyView.m
#import "MyView.h"

@implementation MyView

- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
}
return self;
}

-(void)awakeFromNib {
CALayer * zCALayerRoot = [CALayer layer];
zCALayerRoot.autoresizingMask = kCALayerWidthSizable | 
kCALayerHeightSizable;
zCALayerRoot.needsDisplayOnBoundsChange = YES;
[self setLayer: zCALayerRoot];
[self setWantsLayer:YES];
self.layer.backgroundColor = CGColorCreateGenericRGB(0.0,0.0,1.0,1.0);
} // end awakeFromNib

- (void)drawRect:(NSRect)dirtyRect {
} // end drawRect

@end

> 
>> I get exactly the same behaviour if I leave out all the layer stuff and 
>> instead code the following in the view
>> 
>> - (void)drawRect:(NSRect)dirtyRect {
>>  [[NSColor blackColor]set];
>>  [NSBezierPath fillRect:[self bounds]];
>> } // end drawRect
> 
> Well, in that case the struts (which end up setting the autoresizing mask for 
> the view) must either be set incorrectly,
I went back into IB to check this. As far as I can tell everything is set 
correctly.
I have put a copy of the project up here
http://juliuspaintings.co.uk/cocoa/LayersInView3.zip

I have also put a copy of the project which contains only the view - no layers 
here
http://juliuspaintings.co.uk/cocoa/LayersInView2.zip



> or else the view in IB that you think you're setting is not the view object 
> you actually end up with in  your window. A common mistake is to add the view 
> in IB and also create and add it in code. Do one or the other, never both.
Only created it in IB

Julius


http://juliuspaintings.co.uk



___

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

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

2011-08-08 Thread Graham Cox
Thanks Thomas, I'll check it out.

--Graham


On 08/08/2011, at 6:24 PM, Thomas Davie wrote:

> You're right – the vertices are here specified in OpenGL "clip space" – a 
> coordinate system stretching from -1 to 1 on all 3 axes.  If you want to 
> specify points in a different coordinate space, it's your responsibility to 
> make sure that they end up in clip space, by transforming them appropriately. 
>  In old world GL (as you have there) this is done through the fixed function 
> transform:
> 
> vertex in model space -- * modelview matrix -> vertex in world space -- * 
> projection matrix -> vertex in clip space -- divide x,y,z by w -> vertex in 
> normalised device space -- viewport transform -> vertex in pixel space
> 
> I would however *highly* recommend not using old world GL.  It will make your 
> later transition to OpenGL 3.2 core much much harder, as most of the 
> functions here (glMatrixMode, glPushMatrix, glRotate, glBegin, glColor, 
> glVertex, glEnd, glPopMatrix, and many others) are no longer present.
> 
> To get an idea of how to get started with modern OpenGL, take a look at 
> https://github.com/beelsebob/Cocoa-GL-Tutorial and 
> https://github.com/beelsebob/Cocoa-GL-Tutorial-2.  These are still written in 
> OpenGL 2.1, but in a way that the port to 3.2 when you come to it is 
> trivially easy.
> 
> Thanks
> 
> Tom Davie
> 
> if (*ra4 != 0xffc78948) { return false; }
> 
> On 8 Aug 2011, at 08:35, Graham Cox wrote:
> 
>> I'm looking at using CAOpenGLLayer to boost drawing performance. I'm a total 
>> novice at OpenGL.

___

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

Please do not post admin requests or moderator comments to the list.
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: resizing window containing NSView with CALayer

2011-08-08 Thread Graham Cox
OK, I downloaded the project (tip: always get rid of the build folder before 
posting a project - it makes the difference between a 5 MB download and one 
that's only a few K, which on your server, added up to many minutes).

Result - it works completely correctly and normally. The view resizes with the 
window and redraws as expected.

Whatever the problem you're having is, it's not to do with the code itself. Try 
doing a clean build and trying again.



--Graham




On 08/08/2011, at 7:14 PM, julius wrote:

> I went back into IB to check this. As far as I can tell everything is set 
> correctly.
> I have put a copy of the project up here
> http://juliuspaintings.co.uk/cocoa/LayersInView3.zip
> 
> I have also put a copy of the project which contains only the view - no 
> layers here
> http://juliuspaintings.co.uk/cocoa/LayersInView2.zip
> 
> 

___

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

Please do not post admin requests or moderator comments to the list.
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: CoreData "I/O error for database: no such table"

2011-08-08 Thread Nick Shore
Nick,

I was in fact using existing databases - actually the update I'm working on has 
a migration involved in it too. I didn't mention it originally as I'd ruled it 
out as the cause, but that actually helped fix the problem. Since I was already 
migrating the data (with custom entity migration policies) it was trivial to 
rename the relationships at the same time. And that worked - the migration can 
read the existing database and it fixed my issue when attempting to read the 
new one.

I'm not sure if that would help, and if it did, whether it would be a better 
solution, but I wanted to point it out as throwing out existing data was not an 
option for me either. Maybe it's worth trying a migration and seeing if you can 
get things upgraded correctly that way? A little heavy handed for what does 
indeed seem to be a nasty regression, but better than losing data.

I realise it's not exactly the same problem as I was seeing, but they do seem 
to have a lot in common. 

HTH,
-nick


On 06/08/2011, at 3:55 AM, Keary Suska wrote:

> On Aug 4, 2011, at 2:30 PM, Nick Zitzmann wrote:
> 
>> I tried searching around and found one other person who had the same 
>> problem[1], but no one followed up with a good solution for existing 
>> databases.
>> 
>> I have an entity with a many-to-many relationship to itself, called 
>> "parents" and "children". And when I take a database that was made by an 
>> application built by Xcode 3.2.6 and move that application to Xcode 4.1, I'm 
>> now getting this error when trying to look up something in that entity:
>> 
>> I/O error for database at /path/to/mydatabase.db.  SQLite error code:1, 'no 
>> such table: Z_16PARENTS'
>> 
>> It looks like the model compiler made a subtle change to the many-to-many 
>> table that is part of the model used to make the database during the switch. 
>> How do I make it so that it uses the same tables that it used to use? 
>> Throwing out and rebuilding the existing database is not an option.
>> 
>> I already tried changing the Mac OS X deployment target, since I noticed 
>> that the deployment target is passed to momc, but that did not make any 
>> difference.
>> 
>> I was able to work around the problem by creating a custom build rule that 
>> builds the data model using Xcode 3's momc tool instead of Xcode 4's tool, 
>> and while that did solve the problem, there has got to be a better way. But 
>> what is that way? I can't believe Xcode 4 would ship with such a regression 
>> in momc...
>> 
> 
> Depending on the number of differences you could simply fire up the sqlite 
> client and rename the tables in the database to what the new model compiler 
> generates.
> 
> HTH,
> 
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/macdive%40thedoorisajar.org
> 
> This email sent to macd...@thedoorisajar.org

___

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

Please do not post admin requests or moderator comments to the list.
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: resizing window containing NSView with CALayer

2011-08-08 Thread julius

On 8 Aug 2011, at 11:23, Graham Cox wrote:

> OK, I downloaded the project (tip: always get rid of the build folder before 
> posting a project - it makes the difference between a 5 MB download and one 
> that's only a few K, which on your server, added up to many minutes).
Sorry about that.
Have replaced them.
> 
> Result - it works completely correctly and normally. The view resizes with 
> the window and redraws as expected.
> 
> Whatever the problem you're having is, it's not to do with the code itself. 
> Try doing a clean build and trying again.

Then that is truly a mystery.
I've cleaned and rebuilt.
When I go and drag the resize handle to make the window as small as I can make 
it, i.e. so the window's content rect has zero height then the view misbehaves, 
i.e. the top of the view shifts from being some 100 pixels below the title bar 
to being 0 pixels below it!

Amazing.
Must have done something to my machine then: Mac Pro, OS X 10.6.8  XCode 3.2.6

thanks for your efforts
I was going to put a constraint on window size anyway but now that is essential.
best wishes

Julius  


http://juliuspaintings.co.uk



___

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

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

2011-08-08 Thread Chris Ridd

On 8 Aug 2011, at 08:13, vincent habchi wrote:

>> Some apps, including iTunes, using /Users/Shared/ for DRM.  It may still be 
>> world-writable in Lion [which I can't confirm as I haven't switched 
>> yet...come on 10.7.2...].
> 
> I can confirm /Users/Shared is world writable on 10.7; besides, it has the 
> sticky (8) bit set, just like /tmp.

Does OS X really support the sticky bit? Lion's  suggests "no", 
though this line could be read a couple of ways:

#define S_ISTXT S_ISVTX /* sticky bit: not supported */

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: Core Data : User missing inverse relationship despite model settings

2011-08-08 Thread Jerry Krinock
I forgot to say that this is on Mac.  One error report came from Snow Leopard 
and the other from Lion.  Store is 
SQLite.___

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

Please do not post admin requests or moderator comments to the list.
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: resizing window containing NSView with CALayer

2011-08-08 Thread Graham Cox

On 08/08/2011, at 9:35 PM, julius wrote:

> When I go and drag the resize handle to make the window as small as I can 
> make it, i.e. so the window's content rect has zero height then the view 
> misbehaves, i.e. the top of the view shifts from being some 100 pixels below 
> the title bar to being 0 pixels below it!


Ummm, well, that's not what you said was going on originally. This is normal.

The reason this happens is that once either the width or height goes to 0, 
there's nothing for the view sizing code to mutliply by to end up with the 
destination size - once you hit a zero, the sizing information is lost. To 
prevent this, set a minimum size on the window. This is a good idea in any case 
- there is no possible use for a zero-sized window.

--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: resizing window containing NSView with CALayer

2011-08-08 Thread julius

On 8 Aug 2011, at 13:23, Graham Cox wrote:

> 
> On 08/08/2011, at 9:35 PM, julius wrote:
> 
>> When I go and drag the resize handle to make the window as small as I can 
>> make it, i.e. so the window's content rect has zero height then the view 
>> misbehaves, i.e. the top of the view shifts from being some 100 pixels below 
>> the title bar to being 0 pixels below it!
> 
> 
> Ummm, well, that's not what you said was going on originally. This is normal.
Very sorry.
I had tried to be as clear as possible.
Sorry then to have led you this wild goose chase.

> 
> The reason this happens is that once either the width or height goes to 0, 
> there's nothing for the view sizing code to mutliply by to end up with the 
> destination size - once you hit a zero, the sizing information is lost. To 
> prevent this, set a minimum size on the window. This is a good idea in any 
> case - there is no possible use for a zero-sized window.
> 
Of course.
Normal behaviour and understandable.
Bit of a surprise when I came across it but!

thanks again
Julius 

http://juliuspaintings.co.uk



___

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

Please do not post admin requests or moderator comments to the list.
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: Release build throw "unrecognized selector sent to instance" for a category method

2011-08-08 Thread Bruno Berisso
Recently we have the same problem in a new project that use a open source 
library. The author of the library suggest the use of tow linker flags: '-ObjC' 
and '-all_load', and guest what?! This is exactly what I need 
(http://developer.apple.com/library/mac/#qa/qa1490/_index.html)

Thanks for your answers.
Regards.


On Jul 31, 2011, at 7:26 AM, Fritz Anderson wrote:

> On 30 Jul 2011, at 10:58 PM, Bruno Berisso wrote:
> 
>> In the library project I use several categories, one of them add some 
>> methods to NSDate to move a date around (ej: 'moveDateToNextMonth'). For 
>> some reason when set the build configuration to Release the calls '[date 
>> moveDateToNextMonth]' in my library project I get the "unrecognized selector 
>> sent to instance" error.
> 
> When the log says moveDateToNextMonth is sent to an instance of something, to 
> what class does it report the message is sent? Along the same lines, have you 
> tried enabling zombies?
> 
>   — 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: resizing window containing NSView with CALayer

2011-08-08 Thread Graham Cox

On 08/08/2011, at 10:42 PM, julius wrote:

>> The reason this happens is that once either the width or height goes to 0, 
>> there's nothing for the view sizing code to mutliply by to end up with the 
>> destination size - once you hit a zero, the sizing information is lost. To 
>> prevent this, set a minimum size on the window. This is a good idea in any 
>> case - there is no possible use for a zero-sized window.
>> 
> Of course.
> Normal behaviour and understandable.
> Bit of a surprise when I came across it but!


There's a fairly easy way to avoid this with layers. If you set a layoutManager 
on the root layer, then it will be called when the host view is resized, and 
you can use that to calculate the content layer's size & position from known 
values. This gives you the ability to lay out layers in a more complex way than 
is possible with the 'struts and springs' model (which is being superseded in 
Lion forward anyway).

I'd suggest that you add a layer to the window which is the size of the window 
at all times, then add any other layers that you want as sublayers of this. 
That way, you have a layer behind everything that you can rely on to host any 
other layers you need. If that root layer sets the view as its layoutManager, 
then you can do this for example:

// in MyView:

- (void)layoutSublayersOfLayer:(CALayer*) layer
{
 CGRect insetRect = CGRectInset(layer.bounds, 30, 30 );  // or however this 
layer relates to the root

 myRealContentLayer.frame = insetRect;
}



This supposes the view has a data member 'myRealContentLayer' which is 
initialised to the layer you created AND ADDED as a sublayer to the master 
layer. So your view's init method might look like this:

- (id)initWithFrame:(NSRect) frame
{
self = [super initWithFrame:frame];
   if( self )
   {
   CALayer* root = [CALayer layer];
   root.frame = NSRectToCGRect( frame );
   self.layer = root;
   [self setWantsLayer:YES];
root.layoutManager = self;
root.autoresizingMask = kCAWidthSizable | kCAHeightSizable;

myRealContentLayer = [CALayer layer];
myRealContentLayer.backgroundColor =// whatever color

   [root addSublayer:myRealContentLayer];
   }
   return self;
}


Doing it this way should make your layer immune from the zero size problem.

--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: resizing window containing NSView with CALayer

2011-08-08 Thread julius

On 8 Aug 2011, at 14:00, Graham Cox wrote:

> 
> Doing it this way should make your layer immune from the zero size problem.
> 
Thanks. That's really helpful.
Amazon's just mailed to say the Core Animation book should be with me in a few 
days.
>From what I've seen and tried so far this layered and managed approach looks 
>beautifully structured and versatile.
Best wishes
Julius 

http://juliuspaintings.co.uk



___

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

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

2011-08-08 Thread Kyle Sluder
On Aug 8, 2011, at 4:54 AM, Chris Ridd  wrote:

> 
> Does OS X really support the sticky bit? Lion's  suggests "no", 
> though this line could be read a couple of ways:

Yep, it's supported and used on directories. Don't think it's supported on 
files, though.

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


Re: Drawing text like Lion's Mail

2011-08-08 Thread Jean-Daniel Dupas

I think you can create a CGPath from some text using CTFrameGetPath().
Once you get the path, you can do whatever you want (clipping, shadow, 
gradient, …).

Le 8 août 2011 à 02:22, Andre Masse a écrit :

> Interesting. Not sure if could be possible to convert the text to an image, 
> apply a gradient and use one of the copy method of NSImage. I needed a break 
> from coding data migration, hence the pause trying this. Now, I'm back to the 
> boring part ;-)
> 
> Looks like your image didn't pass the list. Feel free to email it to me 
> directly.
> 
> Thanks,
> 
> Andre Masse
> 
> 
> On 07/08/2011, at 14:12 , Siegfried wrote:
> 
>> 
>> On 07/08/2011, at 10:52, Andre Masse wrote:
>> 
>>> For those interested, Matt and Kyle were right. Helvetica Neue Bold 20pts. 
>>> All my attempts to replicate the shadow have failed though. I'm using 85% 
>>> white and it's good enough for me.
>>> 
>> 
>> The shadow is just an "inner shadow". The problem is that I have no idea on 
>> how to create an inner shadow in Cocoa. The obvious technique is to apply a 
>> shadow on a white layer that has holes in form of letters. But I also have 
>> no idea on how to do such intersection.
>> 
>> See the attached image and tell me if you like it. By the way, let's see if 
>> you find which one is the original :-)



-- Jean-Daniel




___

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

Please do not post admin requests or moderator comments to the list.
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: Drawing text like Lion's Mail

2011-08-08 Thread Siegfried
On 08/08/2011, at 12:16, Jean-Daniel Dupas wrote:

> I think you can create a CGPath from some text using CTFrameGetPath().
> Once you get the path, you can do whatever you want (clipping, shadow, 
> gradient, …).

Ah, then that's the way to go! Thanks Jean-Daniel.

The image I created used as background a gray ~79% (RGB 201/255). Then, the 
shadow can be applied in a 115º angle or so, 1px distant and size of 3 px. 115º 
in x,y coordinates after a rough calculation gives 0.422 and 0.906 (sin and cos 
of 65º). Also, the color used to produce the shadow was a gray 25%. The result 
is pretty similar.

> 
> Le 8 août 2011 à 02:22, Andre Masse a écrit :
> 
>> Interesting. Not sure if could be possible to convert the text to an image, 
>> apply a gradient and use one of the copy method of NSImage. I needed a break 
>> from coding data migration, hence the pause trying this. Now, I'm back to 
>> the boring part ;-)
>> 
>> 
>> On 07/08/2011, at 14:12 , Siegfried wrote:
>> 
>>> 
>>> On 07/08/2011, at 10:52, Andre Masse wrote:
>>> 
 For those interested, Matt and Kyle were right. Helvetica Neue Bold 20pts. 
 All my attempts to replicate the shadow have failed though. I'm using 85% 
 white and it's good enough for me.
 
>>> 
>>> The shadow is just an "inner shadow". The problem is that I have no idea on 
>>> how to create an inner shadow in Cocoa. The obvious technique is to apply a 
>>> shadow on a white layer that has holes in form of letters. But I also have 
>>> no idea on how to do such intersection.
>>> 
>>> See the attached image and tell me if you like it. By the way, let's see if 
>>> you find which one is the original :-)
> 
> 
> 
> -- Jean-Daniel
> 
___

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

Please do not post admin requests or moderator comments to the list.
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: Xcode 4 core data mapping model not creating inherited attributes/relationships

2011-08-08 Thread Sean McBride
On Sun, 7 Aug 2011 07:39:25 +0200, Martin Hewitson said:

>Is there a know problem or limitation in naming relationships? I haven't
>come across this anywhere before.

Well, you should not name properties with the same name as an NSObject or 
NSMangedObject method name.  ex: don't create a property named 'retain'.  If 
forget if there is a warning about this or not... if not, someone should file a 
bug. :)

--

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: Signing for sandboxing (was NSPersistentDocument: SQLite error 21...)

2011-08-08 Thread Sean McBride
On Sun, 7 Aug 2011 15:41:01 -0500, Fritz Anderson said:

>> I have an NSPersistentDocument, with autosave-in-place enabled. When I
>try to save the document after editing it, it balks with both
>application-modal alerts and document-modal sheets, all with generic
>messages about being unable to create or save the document.
>
>Okay, I tracked this down to Lion sandboxing. If I remove my signature
>and the entitlements from the app, it saves just fine.

Sandboxing, IMNSHO, is still half-baked.  Note that on Lion, only TextEdit and 
Preview have it enabled.  That should tell you something.  I tried with my app, 
and hit bug after bug.  In addition to limitation after limitation.

--

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: Telling Auto Save, "No, I'm busy now"

2011-08-08 Thread Kevin Perry
Ah, I did not foresee this.

I really can't generally recommend calling -saveToURL:::error: instead of 
saveToURL:::completionHandler: because the latter does some important things 
that the former doesn't. Unfortunately, I think the problem you're seeing with 
the hang is insurmountable without additional API. Here's what normally happens:

1) -autosaveWithImplicitCancellability:completionHandler: uses 
-performAsynchronousFileAccessUsingBlock:
2) Within that block, it calls -saveToURL:::completionHandler:
3) -saveToURL:::completionHandler: of necessity also uses 
-performAsynchronousFileAccessUsingBlock:. When invoked in the above block, 
NSDocument recognizes this as a continuation of the initial 
-performAsynchronousFileAccessUsingBlock: call and simply invokes the block 
right away.

However, in your case, you are delaying step (3) until outside the initial 
block, so NSDocument cannot automatically recognize this as a continuation of 
the same file access. In order to resolve this, you would need API on 
NSDocument to tell it that you're continuing the same file access from before 
when you reinvoke -saveToURL:::completionHandler:.


Actually, you may be able to work around this problem by overriding 
-autosaveWithImplicitCancellability:completionHandler: instead (also?) and 
doing the same approach of delaying NSDocument's code until once you've 
completed the background work.

-KP

On Aug 6, 2011, at 7:23 AM, Jerry Krinock wrote:
> ** One little surprise.  After dequeueing the save operation, I kind of 
> thought that I could invoke the new synchronous saving method 
> saveToURL:::completionHandler:.  However, this does not save and apparently 
> does not run the completion handler properly because I still get the 
> hanging/blocking in -[NSDocument performAsynchronousFileAccessUsingBlock:].  
> But if I invoke the old async -saveToURL:::error: method and invoke the 
> completion handler block "manually", it works fine.  Here…
> 
> /*!
> @briefReal saving method, invoked when a save operation is
> dequeued to do the actual work.
> */
> - (void)reallySaveToURL:(NSURL *)url
> ofType:(NSString *)typeName
>   forSaveOperation:(NSSaveOperationType)saveOperation
>  completionHandler:(void (^)(NSError *errorOrNil))completionHandler {
>[self prepareForSaveOperation:saveOperation] ;
> 
> #if 0
> #warning Using fancy new async saveToURL.  Doesn't work.
>[super saveToURL:url
>  ofType:typeName
>forSaveOperation:saveOperation
>   completionHandler:completionHandler] ;
>// Still hangs even if the following is commented out.
>Block_release(completionHandler) ;
> #else
> #warning Invoking completionHandler manually.  This works.
>NSError* error = nil ;
>BOOL ok = [super saveToURL:url
>ofType:typeName
>  forSaveOperation:saveOperation
> error:&error] ;
>completionHandler(error) ;
>Block_release(completionHandler) ;
>if (error && ok) {
>NSLog(@"Internal Error 923-0284 %@", error) ;
>}
> #endif
> }
> 
> 
> /*!
> @briefOverride of new asynchronous saving method invoked by Cocoa
> when running in Mac OS X 10.7 or later.
> 
> @details  
> 
> * Case  saveOperation  maenQueue  Cancellable?  Action
> *   -  -    
> *   1  not AIP X   XAdd to queue
> *   2AIP   not busyXAdd to (empty) queue
> *   3AIP busyYesCancel the Save
> *   4AIP busy NoAdd to (busy) queue
> 
> AIP = Auto Save In Place
> X = don't care
> */
> - (void)saveToURL:(NSURL *)url
>   ofType:(NSString *)typeName
> forSaveOperation:(NSSaveOperationType)saveOperation
> completionHandler:(void (^)(NSError *errorOrNil))completionHandler {
>if (saveOperation == NSAutosaveInPlaceOperation) {
>// Case 2, 3 or 4
>if ([[[SSYOperationQueue maenQueue] operations] count] != 0) {
>// Case 3 or 4  (busy)
>  if ([self autosavingIsImplicitlyCancellable]) {
>// Case 3.  Cancel the Save
>completionHandler([NSError errorWithDomain:NSCocoaErrorDomain
>  code:NSUserCancelledError
>  userInfo:nil]) ;
>/*DB?Line*/ NSLog(@"133955: Cancelling Save") ;
>return ;
>}
>else {
>// Case 4.  Add to (busy) queue
>}
>}
>else {
>// Case 2.  Add to (empty) queue
>}
>}
>else {
>// Case 1.  Add to queue
>}
> 
>// Note that we arrive here either in Case 1, 2 or 4.
>// In Case 2, and maybe Case 1, instead of adding the save
>// operation to our queue, we could invoke -reallySaveToURL
>// synchronously.  However we don't do that

Re: CFURLWriteDataAndPropertiesToResource as root?

2011-08-08 Thread Sean McBride
On Mon, 8 Aug 2011 01:04:07 -0600, Eli Bach said:

>> It's a validation file containing registration details. My product is
>an AudioUnit plugin so there's no App Store potential but I'd prefer to
>keep things clean just in case.
>>
>> I don't care where I write the file much (previously I wrote it to "/
>Library/Preferences") but even the hard drive root path is off limits.
>Other suggestions include writing data into the keychain but this is
>just a Lion compatibility fix and I'm not sure how keychain access from
>within an AU would work out in practice.
>>
>> I register the whole machine rather than individual users. Any other
>suggestions as to where to write it?
>> Stephen
>
>Some apps, including iTunes, using /Users/Shared/ for DRM.  It may still
>be world-writable in Lion [which I can't confirm as I haven't switched
>yet...come on 10.7.2...].

It's still writable.

I fear that many apps will now start saving all kinds of stuff willy-nilly into 
this folder, instead of with the nice structure in /Library.

Sometimes one wants to save preferences at the machine domain, and 
kCFPreferencesAnyUser lets you do this, though you'll need to use SMJobBless() 
to do so.

--

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


Lion code-signing at all (was Re: Signing for sandboxing, etc)

2011-08-08 Thread Fritz Anderson
On 8 Aug 2011, at 11:28 AM, Sean McBride wrote:

> Sandboxing, IMNSHO, is still half-baked.  Note that on Lion, only TextEdit 
> and Preview have it enabled.  That should tell you something.  I tried with 
> my app, and hit bug after bug.  In addition to limitation after limitation.

Ah. Given that we are less than three months from its being mandatory (for the 
App Store), that is not encouraging. I'll lay off sandboxing for the moment.

I may not have made clear in my OP that I still have a problem. I can't get my 
app to launch at all if it is code-signed, even if I turn off entitlements. I 
think I've followed all the instructions, but the instructions are ambiguous 
and often out-of-sync with reality. And I'm rather dense.

Code signing has been required for App Store submission for months, so I know 
that this part of the problem, at least, has been solved. Is there a tutorial I 
should be reviewing?

Here's my original posting, for reference:

> I've been trying to put a proper signature on it. I got a development 
> provisioning profile that matches my app ID and my signing certifcate. The 
> machine I'm running on is on the profile. It's in the Organizer. The Build 
> Settings for the app target show the signing identity to match my 
> certificate, which it says is pulled from the profile for the app's ID. When 
> I run, or build for running (cmd-B), the app builds cleanly.
> 
> But when I run (from Xcode or the Finder, the app is shut down immediately. 
> This is in the Console:
> 
> 8/7/11 3:22:36.402 PM sandboxd: ([68116]) taskgated-helper(68116) deny 
> file-read-metadata /private/var/db/DetachedSignatures
> 8/7/11 3:22:36.405 PM sandboxd: ([68116]) taskgated-helper(68116) deny 
> file-read-data /private/var/db/DetachedSignatures
> 
> The stack traces go through Security::CodeSigning, among other things.
> 
> Is it strange that the app would launch (just run into file sandboxing) 
> before I got a provisioning profile?
> 
> Provisioning has always been a dark art, so I'm sure I'm doing something 
> wrong. What is it?

— 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: Core Data : User missing inverse relationship despite model settings

2011-08-08 Thread Sean McBride
On Mon, 8 Aug 2011 01:12:36 -0700, Jerry Krinock said:

>The reports indicate (rather strangely, but I'm watching my word count
>here) that the problem is "Dangling reference to an invalid object".
>Searching list archives tells me that this has been due to setting a
>relationship in -awakeFromFetch, which is illegal.  But I checked my
>project carefully and I'm not doing that.

hmmm, I'm having deja vu.  Are you sure you're not setting a relationship in 
awakeFromFetch?  IIRC, when I had a similar problem, it was because of an 
unanticipated chain of faulting/fetching that caused awakeFrom to be somewhere 
on the backtrace.  Ahh, here's the Radar... rdar://7361717

---
03-Nov-2009 05:25 PM Sean McBride:
The docs for awakeFromFetch warn "you should not modify relationships in this 
method as the inverse will not be set".

Despite knowing that well (after learning it the hard way long ago), I found 
another place where I do so.  But not in a direct way!  A controller object is 
using KVO to observe many things.  Sometimes in response to these changes, it 
ends of firing a fault, which leads to more KVO, etc.  Suffice to say that I 
ended up with awakeFromFetch in the backtrace (30 frames ago) and then changed 
a relationship. :(

It would be great if the Core Data _debug variant could test for this and warn 
if it detects it happening.
---

I remember thinking that mogenerator could be changed to implement 
awakeFromFetch everywhere, call backtrace() and assert, but never got to it...

hth,

--

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: Drawing text like Lion's Mail

2011-08-08 Thread David Duncan
On Aug 8, 2011, at 8:16 AM, Jean-Daniel Dupas wrote:

> 
> I think you can create a CGPath from some text using CTFrameGetPath().
> Once you get the path, you can do whatever you want (clipping, shadow, 
> gradient, …).


CTFrameGetPath() returns the path used to create the frame, typically a 
rectangle, not a path that describes the text therein.
--
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


NSCoding to/from JSON?

2011-08-08 Thread Jens Alfke
Been thinking about archiving NSObjects to/from JSON, using an API similar to 
NSCoding. I haven’t found any prior art, but I thought I’d ask here.

I am not talking about serializing JSON to/from collection objects a la 
TouchJSON, JSONKit, etc.; rather, something that lets you convert your custom 
model objects into JSON and back. And I want it to be clean JSON, so that you 
can use this API to unarchive JSON created by any of the zillions of web APIs 
that generate it.

It’s tempting to try to do this using the existing NSArchiving protocol and 
writing a custom NSKeyed[Un]Archiver subclass. This doesn’t work, at least for 
my purposes, because JSON has a limited set of data types and I don’t want to 
clutter up the output with extra type annotations. For example, say the JSON 
contains a date. JSON doesn’t have a date type, so the convention is to 
represent the date as a string in ISO-8661 format. But calling 
-decodeObjectForKey: will return an NSString instead of an NSDate. To get 
around this you have to add methods like -decodeDateForKey: that make it more 
clear what you’re expecting. (The same goes for other common value classes like 
NSData.)

—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


Re: Asynchronous downloading and parsing of XML

2011-08-08 Thread Mikkel Islay
Thanks for the explanation, Jens too.
The hint that NSXMLParser has that behaviour is that it accepts an 
NSInputStream, or that it relies on a delegate for communicating "parse-events"?

Mikkel


On 8 Aug 2011, at 10:34, Andreas Grosam wrote:

> No. Asynchronous routines can be implemented above a blocking interface. 
> Blocking and asynchronous interfaces work well together, and you may not even 
> notice the existence of a blocking interface since it is working under the 
> hood as an implementation detail.
> 
> For instance the parser *could* (we don't know) be implemented as a 
> "recursive decent" parser. This kind of parser will effectively require that 
> the parsing routine blocks, when there is no further input available, since 
> the state of the parser will be in its call stack. So you can't just stop and 
> exit the parse function in the middle of a stream, and then continue with a 
> newly invoked method when more data is available. 
> 
> The parser would just dispatch its events on the main thread where the 
> delegate can handle them. So, from the view point of the delegate, it looks 
> like an asynchronous interface.
> 
___

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

Please do not post admin requests or moderator comments to the list.
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: Asynchronous downloading and parsing of XML

2011-08-08 Thread Thomas Davie
The hint is that the NSXMLParser docs say:

Parameters
stream
The input stream. The content is incrementally loaded from the specified stream 
and parsed.

if (*ra4 != 0xffc78948) { return false; }

On 8 Aug 2011, at 17:59, Mikkel Islay wrote:

> Thanks for the explanation, Jens too.
> The hint that NSXMLParser has that behaviour is that it accepts an 
> NSInputStream, or that it relies on a delegate for communicating 
> "parse-events"?
> 
> Mikkel
> 
> 
> On 8 Aug 2011, at 10:34, Andreas Grosam wrote:
> 
>> No. Asynchronous routines can be implemented above a blocking interface. 
>> Blocking and asynchronous interfaces work well together, and you may not 
>> even notice the existence of a blocking interface since it is working under 
>> the hood as an implementation detail.
>> 
>> For instance the parser *could* (we don't know) be implemented as a 
>> "recursive decent" parser. This kind of parser will effectively require that 
>> the parsing routine blocks, when there is no further input available, since 
>> the state of the parser will be in its call stack. So you can't just stop 
>> and exit the parse function in the middle of a stream, and then continue 
>> with a newly invoked method when more data is available. 
>> 
>> The parser would just dispatch its events on the main thread where the 
>> delegate can handle them. So, from the view point of the delegate, it looks 
>> like an asynchronous interface.
>> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com
> 
> This email sent to tom.da...@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: Asynchronous downloading and parsing of XML

2011-08-08 Thread Mikkel Islay
On 8 Aug 2011, at 19:04, Thomas Davie wrote:
> 
> Parameters
> stream
> The input stream. The content is incrementally loaded from the specified 
> stream and parsed.

No, that states something about the way NSXMLParser is able to parse from a 
stream. It doesn't say anything about its state with respect to the main thread.

Mikkel___

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

Please do not post admin requests or moderator comments to the list.
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: Asynchronous downloading and parsing of XML

2011-08-08 Thread Thomas Davie
On 8 Aug 2011, at 18:16, Mikkel Islay wrote:

> On 8 Aug 2011, at 19:04, Thomas Davie wrote:
>> 
>> Parameters
>> stream
>> The input stream. The content is incrementally loaded from the specified 
>> stream and parsed.
> 
> No, that states something about the way NSXMLParser is able to parse from a 
> stream. It doesn't say anything about its state with respect to the main 
> thread.

I'm not sure what you're getting at… The key facts are…

NSURLConnection provides data incrementally.
The URLConnection delegate takes that data incrementally and provides it to the 
stream incrementally.
The Stream takes the data incrementally and provides it to the parser as it 
gets it.
The XML parser takes the data incrementally and calls the delegate when it 
parses something successfully.

All of this is asynchronous, so everything works happily :)

Tom Davie___

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

Please do not post admin requests or moderator comments to the list.
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: Drawing text like Lion's Mail

2011-08-08 Thread Jean-Daniel Dupas

Le 8 août 2011 à 18:50, David Duncan a écrit :

> On Aug 8, 2011, at 8:16 AM, Jean-Daniel Dupas wrote:
> 
>> 
>> I think you can create a CGPath from some text using CTFrameGetPath().
>> Once you get the path, you can do whatever you want (clipping, shadow, 
>> gradient, …).
> 
> 
> CTFrameGetPath() returns the path used to create the frame, typically a 
> rectangle, not a path that describes the text therein.

My bad.
So I guess the only way to get the path is to use CTFontCreatePathForGlyph() on 
each glyph and using other CT methods to get there positions.
Not as convenient, but possible, especially if this is for a single line of 
text as requested by the OP.

-- Jean-Daniel




___

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

Please do not post admin requests or moderator comments to the list.
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: Drawing text like Lion's Mail

2011-08-08 Thread David Duncan
On Aug 8, 2011, at 10:21 AM, Jean-Daniel Dupas wrote:

> Le 8 août 2011 à 18:50, David Duncan a écrit :
> 
>> On Aug 8, 2011, at 8:16 AM, Jean-Daniel Dupas wrote:
>> 
>>> 
>>> I think you can create a CGPath from some text using CTFrameGetPath().
>>> Once you get the path, you can do whatever you want (clipping, shadow, 
>>> gradient, …).
>> 
>> 
>> CTFrameGetPath() returns the path used to create the frame, typically a 
>> rectangle, not a path that describes the text therein.
> 
> My bad.
> So I guess the only way to get the path is to use CTFontCreatePathForGlyph() 
> on each glyph and using other CT methods to get there positions.
> Not as convenient, but possible, especially if this is for a single line of 
> text as requested by the OP.


If you just need the text outlines for clipping, then you should be able to use 
the Text Drawing mode of the context. By setting it to kCGText*Clip, the 
clipping region is set to that of the text after it is "drawn".

Unfortunately there is no simple way to get the path this way if it is what you 
need (at least not that I can tell). CTFontCreatePathForGlyph() is one way to 
go about it, and I think a combination of NSLayoutManager and NSBezierPath can 
also do it, although I believe you have to subclass NSLayoutManager to do so (I 
haven't done this, but I recall Aki Inoue outlining it to me a long time ago). 
If you are already using NSLayoutManager this would probably be the way to go 
since your metrics won't change as much going this route.
--
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Asynchronous downloading and parsing of XML

2011-08-08 Thread Jens Alfke

On Aug 8, 2011, at 10:16 AM, Mikkel Islay wrote:

> No, that states something about the way NSXMLParser is able to parse from a 
> stream. It doesn't say anything about its state with respect to the main 
> thread.

It’s clearly a SAX parser. SAX parsers are incremental, that’s their whole 
point, otherwise it would be easier just to use a DOM API like NSXMLDocument.

—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


Re: CFURLWriteDataAndPropertiesToResource as root?

2011-08-08 Thread Stephen Blinkhorn


On 8 Aug 2011, at 10:36, Sean McBride wrote:


On Mon, 8 Aug 2011 01:04:07 -0600, Eli Bach said:

It's a validation file containing registration details. My product  
is
an AudioUnit plugin so there's no App Store potential but I'd  
prefer to

keep things clean just in case.


I don't care where I write the file much (previously I wrote it to  
"/
Library/Preferences") but even the hard drive root path is off  
limits.

Other suggestions include writing data into the keychain but this is
just a Lion compatibility fix and I'm not sure how keychain access  
from

within an AU would work out in practice.


I register the whole machine rather than individual users. Any other

suggestions as to where to write it?

Stephen


Some apps, including iTunes, using /Users/Shared/ for DRM.  It may  
still
be world-writable in Lion [which I can't confirm as I haven't  
switched

yet...come on 10.7.2...].


It's still writable.

I fear that many apps will now start saving all kinds of stuff willy- 
nilly into this folder, instead of with the nice structure in / 
Library.


I'm afraid your fears have just been confirmed, until I find a better  
solution at least. Maybe I can justify this as a kind of protest  
against AudioUnits not being allowed in the App Store :-)


Thanks to everyone who helped!

Stephen



Sometimes one wants to save preferences at the machine domain, and  
kCFPreferencesAnyUser lets you do this, though you'll need to use  
SMJobBless() to do so.


--

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/stephen%40audiospillage.com

This email sent to step...@audiospillage.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: CFURLWriteDataAndPropertiesToResource as root?

2011-08-08 Thread Kyle Sluder
On Mon, Aug 8, 2011 at 11:13 AM, Stephen Blinkhorn
 wrote:
> I'm afraid your fears have just been confirmed, until I find a better
> solution at least. Maybe I can justify this as a kind of protest against
> AudioUnits not being allowed in the App Store :-)

Well, writing to /Users/Shared isn't going to pass the MAS guidelines anyway.

And writing anywhere that you haven't been granted access to via
NSSavePanel is going to fail under Sandboxing.

So it might be time to start thinking about whether you really need to
be writing in arbitrary locations on the disk.

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


Re: CFURLWriteDataAndPropertiesToResource as root?

2011-08-08 Thread Andrew Thompson
But doesn't it seem entirely reasonable that apps signed by the same vendor 
(for example) be able to share files? I mean in a safe location perhaps with a 
limited quota of space?

Cookies and client side storage in HTML 5 allow this (not exactly the same but 
still), but native apps have no options?



On Aug 8, 2011, at 2:21 PM, Kyle Sluder  wrote:

> On Mon, Aug 8, 2011 at 11:13 AM, Stephen Blinkhorn
>  wrote:
>> I'm afraid your fears have just been confirmed, until I find a better
>> solution at least. Maybe I can justify this as a kind of protest against
>> AudioUnits not being allowed in the App Store :-)
> 
> Well, writing to /Users/Shared isn't going to pass the MAS guidelines anyway.
> 
> And writing anywhere that you haven't been granted access to via
> NSSavePanel is going to fail under Sandboxing.
> 
> So it might be time to start thinking about whether you really need to
> be writing in arbitrary locations on the disk.
> 
> --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/lordpixel%40mac.com
> 
> This email sent to lordpi...@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: CFURLWriteDataAndPropertiesToResource as root?

2011-08-08 Thread Stephen Blinkhorn


On 8 Aug 2011, at 12:21, Kyle Sluder wrote:


On Mon, Aug 8, 2011 at 11:13 AM, Stephen Blinkhorn
 wrote:

I'm afraid your fears have just been confirmed, until I find a better
solution at least. Maybe I can justify this as a kind of protest  
against

AudioUnits not being allowed in the App Store :-)


Well, writing to /Users/Shared isn't going to pass the MAS  
guidelines anyway.


And writing anywhere that you haven't been granted access to via
NSSavePanel is going to fail under Sandboxing.

So it might be time to start thinking about whether you really need to
be writing in arbitrary locations on the disk.


OK, well /Library/Application Support/CompanyName/ is out I believe as  
you're not supposed to store user data in there. Which leaves the  
keychain as the only option I can think of right now. I'll try the  
keychain approach but I don't see it being ideal for an AU plugin that  
users may run from within several host apps.


Alternatively I could distribute key files and have the user specify  
its location.


Stephen




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


Re: NSCoding to/from JSON?

2011-08-08 Thread Andy Lee
You might want to look at Bill Kunz's Objectify and maybe discuss with the 
author.



--Andy

On Aug 8, 2011, at 12:56 PM, Jens Alfke wrote:

> Been thinking about archiving NSObjects to/from JSON, using an API similar to 
> NSCoding. I haven’t found any prior art, but I thought I’d ask here.
> 
> I am not talking about serializing JSON to/from collection objects a la 
> TouchJSON, JSONKit, etc.; rather, something that lets you convert your custom 
> model objects into JSON and back. And I want it to be clean JSON, so that you 
> can use this API to unarchive JSON created by any of the zillions of web APIs 
> that generate it.
> 
> It’s tempting to try to do this using the existing NSArchiving protocol and 
> writing a custom NSKeyed[Un]Archiver subclass. This doesn’t work, at least 
> for my purposes, because JSON has a limited set of data types and I don’t 
> want to clutter up the output with extra type annotations. For example, say 
> the JSON contains a date. JSON doesn’t have a date type, so the convention is 
> to represent the date as a string in ISO-8661 format. But calling 
> -decodeObjectForKey: will return an NSString instead of an NSDate. To get 
> around this you have to add methods like -decodeDateForKey: that make it more 
> clear what you’re expecting. (The same goes for other common value classes 
> like NSData.)
> 
> —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/aglee%40mac.com
> 
> This email sent to ag...@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: CFURLWriteDataAndPropertiesToResource as root?

2011-08-08 Thread Quincey Morris
On Aug 8, 2011, at 11:39 , Stephen Blinkhorn wrote:

> OK, well /Library/Application Support/CompanyName/ is out I believe as you're 
> not supposed to store user data in there.

IIRC, the data you're talking about is registration information, which is *not* 
what (I think) is meant by "user data". In fact, Application Support seems like 
exactly the right place to put this information (issues of trying to "hide" 
registration files from users' casual inspection aside).

That's what's wrong with using /Users/Shared -- that location is for users to 
share their data (i.e. documents) with other users, it's not a developer 
infrastructure location.

But I have to admit I haven't tried to parse the documentation's language on 
these matters in new Lion terms, so the above is definitely FWIW.


___

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

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

2011-08-08 Thread Jens Alfke

On Aug 8, 2011, at 11:39 AM, Stephen Blinkhorn wrote:

> OK, well /Library/Application Support/CompanyName/ is out I believe as you're 
> not supposed to store user data in there. Which leaves the keychain as the 
> only option I can think of right now.

Keychains are per-user, apart from the system Keychain that I don’t think apps 
have privileges to modify. If you’re setting per-user data, why not just put it 
in ~/Library/Application Support/?

—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


Know when text is edited in any app

2011-08-08 Thread Joshua Garnham

I need to know when text is entered (or anything relating to a delegate method 
happens) in any NSTextView in the active app whether it's my app, TextEdit or 
Safari. Similar to this app here (http://pilotmoon.com/popclip/).


I'm not sure how exactly to go about this and the only thing I have thought of 
so far is becoming a service but I'm not sure if it's the right way to go about 
it and even so where I'd go from there.


Thanks.


Josh



___

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

Please do not post admin requests or moderator comments to the list.
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: Xcode 4 core data mapping model not creating inherited attributes/relationships

2011-08-08 Thread Martin Hewitson

On Aug 8, 2011, at 06:24 PM, Sean McBride wrote:

> On Sun, 7 Aug 2011 07:39:25 +0200, Martin Hewitson said:
> 
>> Is there a know problem or limitation in naming relationships? I haven't
>> come across this anywhere before.
> 
> Well, you should not name properties with the same name as an NSObject or 
> NSMangedObject method name.  ex: don't create a property named 'retain'.

But that's not what I did. I named an relationship with a lower-case version of 
an Entity name. The relationship points to a File entity, so calling the 
relationship 'file' seemed reasonable and rational to me.  

>  If forget if there is a warning about this or not... if not, someone should 
> file a bug. :)

Same here. I don't recall ever reading such a warning in the docs or any of the 
core data books and tutorials I've read. I'll wait awhile to see if anyone else 
remembers seeing this, then file a bug report.

Martin

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


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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

Please do not post admin requests or moderator comments to the list.
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 : User missing inverse relationship despite model settings

2011-08-08 Thread Jerry Krinock

On 2011 Aug 08, at 09:43, Sean McBride wrote:

> Despite knowing that well (after learning it the hard way long ago), I found 
> another place where I do so.  But not in a direct way!  A controller object 
> is using KVO to observe many things.  Sometimes in response to these changes, 
> it ends of firing a fault, which leads to more KVO, etc.

Yes, I probably have a lot of that going on too.

> Suffice to say that I ended up with awakeFromFetch in the backtrace (30 
> frames ago) and then changed a relationship.

I want to make sure this is not harder than I think.

My Foo class has not overridden -awakeFromFetch.

My Bar class does this…

- (void)awakeFromFetch
{
[super awakeFromFetch] ;

NSDictionary* exids = [[self localStoreManager] exidsForBar:self] ;
[self setIvarExids:exids] ;
}

-localStoreManager is an object which accesses a "local" persistent store, 
which it identifies per the Bar object's -managedObjectContext.  Thus, we get 
'exids' from this other store and cache it in  ivarExids which is, as the name 
implies, a regular instance variable.

With this, I conclude that I am clean as far as not setting relationships in 
-awakeFromFetch.  Are there other back doors which I haven't checked?

Jerry___

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

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

2011-08-08 Thread Stephen Blinkhorn


On 8 Aug 2011, at 12:56, Quincey Morris wrote:


On Aug 8, 2011, at 11:39 , Stephen Blinkhorn wrote:

OK, well /Library/Application Support/CompanyName/ is out I believe  
as you're not supposed to store user data in there.


IIRC, the data you're talking about is registration information,  
which is *not* what (I think) is meant by "user data". In fact,  
Application Support seems like exactly the right place to put this  
information (issues of trying to "hide" registration files from  
users' casual inspection aside).


The desire to "hide" was indeed a consideration but Application  
Support it is.

Thanks again,
Stephen




That's what's wrong with using /Users/Shared -- that location is for  
users to share their data (i.e. documents) with other users, it's  
not a developer infrastructure location.


But I have to admit I haven't tried to parse the documentation's  
language on these matters in new Lion terms, so the above is  
definitely FWIW.





___

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

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

2011-08-08 Thread Sean McBride
On Mon, 8 Aug 2011 14:42:54 -0600, Stephen Blinkhorn said:

>>> OK, well /Library/Application Support/CompanyName/ is out I believe
>>> as you're not supposed to store user data in there.
>>
>> IIRC, the data you're talking about is registration information,
>> which is *not* what (I think) is meant by "user data". In fact,
>> Application Support seems like exactly the right place to put this
>> information (issues of trying to "hide" registration files from
>> users' casual inspection aside).
>
>The desire to "hide" was indeed a consideration but Application
>Support it is.

To be clear, you'd need to use ~/Library/App Support not the one in /Library.

You can use the latter, but you'll need to do so via SMJobBless() since it 
requires root on 10.7 (and admin on 10.6).  Going this root is currently 
forbidden by the App Store, if you care about that, ummm, thing.

--

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: [Lion] IBOutlets, strong or weak?

2011-08-08 Thread Sean McBride
On Fri, 5 Aug 2011 15:11:25 -0400, Marc Respass said:

>With Xcode 4, I can drag from a control to the header and Xcode will
>create an outlet and a property. I noticed that Xcode creates a property
>like this
>
>@property (strong) IBOutlet NSTextField *someField;
>
>But I have other code where it is defined weak -- I started this project
>on an earlier build of Xcode . The strong and weak are new ARC types
>replacing retain and assign (if I remember correctly) and I thought that
>NSWindowController and NSViewController retain their top level objects
>so in 10.6 if I wanted to do this, I would make the property "assign".
>Should I be using "strong" as Xcode seems to think now or "weak" as
>Xcode used to think?

I haven't tried ARC, but according to WWDC11 video session 101 at 47:00, 
delegates and outlets should be weak.

--

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: [Lion] IBOutlets, strong or weak?

2011-08-08 Thread Josh Abernathy
According to the AppKit release notes:

"Note that Xcode 4.2 defaults to ARC when creating new projects, and in the 
WWDC seed release, as well as in the latest version available at the time 10.7 
ships, generates outlet declarations that are strong. This is true for outlets 
generated in new projects as well as when adding new outlet declarations from 
Interface Builder. In most cases these should be changed to weak (zeroing or 
not) to avoid cycles that may cause leaks."


On Aug 8, 2011, at 5:21 PM, Sean McBride wrote:

> On Fri, 5 Aug 2011 15:11:25 -0400, Marc Respass said:
> 
>> With Xcode 4, I can drag from a control to the header and Xcode will
>> create an outlet and a property. I noticed that Xcode creates a property
>> like this
>> 
>> @property (strong) IBOutlet NSTextField *someField;
>> 
>> But I have other code where it is defined weak -- I started this project
>> on an earlier build of Xcode . The strong and weak are new ARC types
>> replacing retain and assign (if I remember correctly) and I thought that
>> NSWindowController and NSViewController retain their top level objects
>> so in 10.6 if I wanted to do this, I would make the property "assign".
>> Should I be using "strong" as Xcode seems to think now or "weak" as
>> Xcode used to think?
> 
> I haven't tried ARC, but according to WWDC11 video session 101 at 47:00, 
> delegates and outlets should be weak.
> 
> --
> 
> 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/joshaber%40gmail.com
> 
> This email sent to josha...@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: Drawing text like Lion's Mail

2011-08-08 Thread Andre Masse
Seems like a lot of work for a simple effect. I may play again with this later 
on this project. I have save this thread in Mail which is telling me that 
there's "20 messages selected" using its fancy font effect :-)

Thanks for all infos guys,

Andre Masse



On 08/08/2011, at 13:29 , David Duncan wrote:

> On Aug 8, 2011, at 10:21 AM, Jean-Daniel Dupas wrote:
> 
>> Le 8 août 2011 à 18:50, David Duncan a écrit :
>> 
>>> On Aug 8, 2011, at 8:16 AM, Jean-Daniel Dupas wrote:
>>> 
 
 I think you can create a CGPath from some text using CTFrameGetPath().
 Once you get the path, you can do whatever you want (clipping, shadow, 
 gradient, …).
>>> 
>>> 
>>> CTFrameGetPath() returns the path used to create the frame, typically a 
>>> rectangle, not a path that describes the text therein.
>> 
>> My bad.
>> So I guess the only way to get the path is to use CTFontCreatePathForGlyph() 
>> on each glyph and using other CT methods to get there positions.
>> Not as convenient, but possible, especially if this is for a single line of 
>> text as requested by the OP.
> 
> 
> If you just need the text outlines for clipping, then you should be able to 
> use the Text Drawing mode of the context. By setting it to kCGText*Clip, the 
> clipping region is set to that of the text after it is "drawn".
> 
> Unfortunately there is no simple way to get the path this way if it is what 
> you need (at least not that I can tell). CTFontCreatePathForGlyph() is one 
> way to go about it, and I think a combination of NSLayoutManager and 
> NSBezierPath can also do it, although I believe you have to subclass 
> NSLayoutManager to do so (I haven't done this, but I recall Aki Inoue 
> outlining it to me a long time ago). If you are already using NSLayoutManager 
> this would probably be the way to go since your metrics won't change as much 
> going this route.
> --
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/andre.masse%40videotron.ca
> 
> This email sent to andre.ma...@videotron.ca

___

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

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

2011-08-08 Thread Stephen Blinkhorn


On 8 Aug 2011, at 14:56, Sean McBride wrote:


On Mon, 8 Aug 2011 14:42:54 -0600, Stephen Blinkhorn said:


OK, well /Library/Application Support/CompanyName/ is out I believe
as you're not supposed to store user data in there.


IIRC, the data you're talking about is registration information,
which is *not* what (I think) is meant by "user data". In fact,
Application Support seems like exactly the right place to put this
information (issues of trying to "hide" registration files from
users' casual inspection aside).


The desire to "hide" was indeed a consideration but Application
Support it is.


To be clear, you'd need to use ~/Library/App Support not the one in / 
Library.


OK, no problem in Cocoa with the stringByExpandingTildeInPath: method  
of NSString. More problematic for CFStringRef though. Is there an  
acknowledged way of doing the equivalent with CFStringRefs? I  
appreciate this is nolonger a Cocoa issue.


Stephen




You can use the latter, but you'll need to do so via SMJobBless()  
since it requires root on 10.7 (and admin on 10.6).  Going this root  
is currently forbidden by the App Store, if you care about that,  
ummm, thing.


--

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: CFURLWriteDataAndPropertiesToResource as root?

2011-08-08 Thread Sean McBride
On Mon, 8 Aug 2011 16:13:50 -0600, Stephen Blinkhorn said:

>> To be clear, you'd need to use ~/Library/App Support not the one in /
>> Library.
>
>OK, no problem in Cocoa with the stringByExpandingTildeInPath: method
>of NSString. More problematic for CFStringRef though. Is there an
>acknowledged way of doing the equivalent with CFStringRefs? I
>appreciate this is nolonger a Cocoa issue.

Actually, don't use stringByExpandingTildeInPath:.  Paths are deprecated, you 
should use NSURL or CFURL to reference file system objects.  Instead, do 
something like this:

NSFileManager* fileManager = [[NSFileManager alloc] init];
NSError* error = nil;
NSURL* url = [fileManager URLForDirectory:NSApplicationSupportDirectory

 inDomain:NSUserDomainMask

appropriateForURL:nil

   create:YES

error:&error];

Not sure about at the CF level... you could use FSFindFolder() I guess.

--

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: Drawing text like Lion's Mail

2011-08-08 Thread Chase Latta
Andre,

I was digging through some old code and found this method I wrote awhile ago.  
I remember basing this off of a blog post or email thread but I don't remember 
the original source.  I used this for something real quick so the code is not 
perfect but may be a good starting point to get what you need.  Essentially you 
draw the string into an offscreen bitmap context and then use that to apply a 
mask.  You can then draw a gradient which gives the text a nice gradient.  The 
problem with this code is that it applies the gradient to the entire rect that 
you are passing so if your text is smaller than your rect you might not get the 
results you expect; this should be easy to fix though.  Note that this is a 
category on NSString.  I hope this helps.

Chase

- (void)drawInRect:(NSRect)rect withAttributes:(NSDictionary *)attributes 
andGradient:(NSGradient *)gradient;
{
NSMutableDictionary *maskAttrs; 
if (attributes != nil) 
maskAttrs = [[attributes mutableCopy] autorelease];
else 
maskAttrs = [NSMutableDictionary dictionary];

NSRect maskRect = NSMakeRect(0, 0, rect.size.width, rect.size.height);
[maskAttrs setValue:[NSColor whiteColor] 
forKey:NSForegroundColorAttributeName];
[maskAttrs setValue:[NSColor blackColor] 
forKey:NSBackgroundColorAttributeName];

CGColorSpaceRef grayScale = CGColorSpaceCreateDeviceGray();
CGContextRef maskContext = CGBitmapContextCreate(NULL, rect.size.width, 
rect.size.height, 8, rect.size.width, grayScale, 0);
CGColorSpaceRelease(grayScale);

// Draw the text into an offscreen context
NSGraphicsContext *maskGraphicsContext = [NSGraphicsContext 
graphicsContextWithGraphicsPort:maskContext flipped:NO];
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:maskGraphicsContext];

[self drawInRect:maskRect withAttributes:maskAttrs];

[NSGraphicsContext restoreGraphicsState];

CGImageRef alphaMask = CGBitmapContextCreateImage(maskContext);

CGContextRef ctx = [[NSGraphicsContext  currentContext] graphicsPort];

// Draw the gradient clipped by the mask of the text
CGContextSaveGState(ctx);
CGContextClipToMask(ctx, NSRectToCGRect(rect), alphaMask);
CGFloat angle = -90;

[gradient drawInRect:rect angle:angle];

CGContextRestoreGState(ctx);
CGImageRelease(alphaMask);
}

> Seems like a lot of work for a simple effect. I may play again with this 
> later on this project. I have save this thread in Mail which is telling me 
> that there's "20 messages selected" using its fancy font effect :-)
> 
> Thanks for all infos guys,
> 
> Andre Masse
> 

___

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

Please do not post admin requests or moderator comments to the list.
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: resizing window containing NSView with CALayer

2011-08-08 Thread Ken Ferry
On Mon, Aug 8, 2011 at 5:23 AM, Graham Cox  wrote:

>
> On 08/08/2011, at 9:35 PM, julius wrote:
>
> > When I go and drag the resize handle to make the window as small as I can
> make it, i.e. so the window's content rect has zero height then the view
> misbehaves, i.e. the top of the view shifts from being some 100 pixels below
> the title bar to being 0 pixels below it!
>
>
> Ummm, well, that's not what you said was going on originally. This is
> normal.
>
> The reason this happens is that once either the width or height goes to 0,
> there's nothing for the view sizing code to mutliply by to end up with the
> destination size - once you hit a zero, the sizing information is lost. To
> prevent this, set a minimum size on the window. This is a good idea in any
> case - there is no possible use for a zero-sized window.


See also Cocoa Auto Layout, which addresses this issue among others.  (Have
people caught this? I'm a little surprised there hasn't been more chatter.
 We're replacing the autoresizing mask entirely.)

Programming 
guide,
release 
notes,
IB 
docs,
sample 
code,
WWDC 
video
.

-Ken
Cocoa Frameworks
___

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

Please do not post admin requests or moderator comments to the list.
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: resizing window containing NSView with CALayer

2011-08-08 Thread Kyle Sluder
On Mon, Aug 8, 2011 at 4:37 PM, Ken Ferry  wrote:
> See also Cocoa Auto Layout, which addresses this issue among others.  (Have
> people caught this? I'm a little surprised there hasn't been more chatter.
>  We're replacing the autoresizing mask entirely.)

I would imagine it will get more popular as people have the luxury and
time to rewrite their interfaces to target Lion only.

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


Re: help with this error

2011-08-08 Thread Rick C.
Yes the error is coming apparently when it tries to move a file which needs an 
administrator password.  Thing is a panel is presented asking for permission 
and even if you just cancel it this error doesn't appear.  And this is not 
something new meaning this project has been ran on many machines before without 
this error (to my knowledge).  So I'm just trying to figure out what can be 
causing the error when I have never experienced it before.  How else could I go 
about troubleshooting this?  Thanks!



On Aug 8, 2011, at 9:31 AM, John Joyce wrote:

> 
> On Aug 8, 2011, at 10:04 AM, Rick C. wrote:
> 
>> Hi again,
>> 
>> Does anyone know what could cause my app to trigger this error in Console:
>> 
>> kernel: mcxalr{4} ** Denying execute for uid=504 appname
>> 
>> Any insight would be much appreciated thanks!
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Privileges & permissions? 
> Make sure the process initiating this has the appropriate level of privileges.
> 

___

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

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


Decimation - NSBezierPath or something else?

2011-08-08 Thread N!K
Does NSBezierPath do decimation as well as interpolation? I didn't find it in 
the Class Reference.
Or is there another class that does it? 
Or must I do the decimation before plotting the data with NSBezierPath?

Decimation reduces the original sampling rate for a sequence to a lower rate, 
the opposite of interpolation. The decimation process filters the input data 
with a lowpass filter and then resamples the resulting smoothed signal at a 
lower rate.


In my application, the math generates  hundreds of points for accuracy, for 
every one that needs to be plotted to make a decent looking plot. Signal 
processing theory says that you can't just throw away points, or you can 
generate errors.

For example, I might generate 25,000 points and be happy to look at a 200 point 
plot. Throwing 25,000 points at NSBezierPath might swamp it, or at least run 
very slowly.

Nick___

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

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

2011-08-08 Thread Sean McBride
On Tue, 9 Aug 2011 08:14:15 +0800, Rick C. said:

>Yes the error is coming apparently when it tries to move a file which
>needs an administrator password.  Thing is a panel is presented asking
>for permission and even if you just cancel it this error doesn't
>appear.  And this is not something new meaning this project has been ran
>on many machines before without this error (to my knowledge).  So I'm
>just trying to figure out what can be causing the error when I have
>never experienced it before.  How else could I go about troubleshooting
>this?  Thanks!

Is this error new in Lion?  There were many permission changes there.  Have you 
tried with a non-admin user?

--

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


NSPrinter deviceDescription

2011-08-08 Thread koko
The docs say NSPrinter deviceDescription dictionary is only guaranteed to have 
the key NSDeviceIsPrinter.

This being the case what is best method for finding the points per inch of a 
selected printer?

-koko


___

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

Please do not post admin requests or moderator comments to the list.
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: Decimation - NSBezierPath or something else?

2011-08-08 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/8/11 5:16 PM, N!K wrote:
> Does NSBezierPath do decimation as well as interpolation? I didn't 
> find it in the Class Reference. Or is there another class that does 
> it? Or must I do the decimation before plotting the data with 
> NSBezierPath?
> 
> Decimation reduces the original sampling rate for a sequence to a 
> lower rate, the opposite of interpolation. The decimation process 
> filters the input data with a lowpass filter and then resamples the 
> resulting smoothed signal at a lower rate.
> 
> 
> In my application, the math generates  hundreds of points for 
> accuracy, for every one that needs to be plotted to make a decent 
> looking plot. Signal processing theory says that you can't just
> throw away points, or you can generate errors.

Not ringing a bell, but this sounds more along the lines of signal
processing than pure drawing.  (NSBezierPath is for arbitrary drawing,
not plotting per se.)

You might find some useful goodies in the Accelerate framework
(http://developer.apple.com/library/mac/#documentation/Accelerate/Reference/AccelerateFWRef/_index.html),
but I've only just barely started learning about it myself.

> For example, I might generate 25,000 points and be happy to look at
> a 200 point plot. Throwing 25,000 points at NSBezierPath might swamp 
> it, or at least run very slowly.

The obligatory question: is this conjecture or have you found this to be
the case?

I have some code that plots about 7500 points in a scalable, scrollable
NSView using NSBezierPath (without attempting any fancy optimization)
and I see absolutely no delay at all during either the initial render or
subsequent transformations.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOQIAoaOlrz5+0JdURArwDAJ4vmVoJWVJFDANlgMG1XTwA0uvcjQCfWS/l
lbWVdwHp2SPVO/N+pTvPL6s=
=w8Ez
-END PGP 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: Decimation - NSBezierPath or something else?

2011-08-08 Thread Wim Lewis

On 8 Aug 2011, at 5:16 PM, N!K wrote:
> Does NSBezierPath do decimation as well as interpolation? I didn't find it in 
> the Class Reference.
> Or is there another class that does it? 
> Or must I do the decimation before plotting the data with NSBezierPath?

No, NSBezierPath doesn't do any kind of decimation or filtering. You'll need to 
do that yourself and then use something like NSBezierPath or CGContextAddLines 
to draw your curve once you've filtered and subsampled your data.


Also, FWIW, the last time I tried to do that (which was a long time ago, around 
the 10.1/10.2 timeframe) I discovered that Quartz took a superlinear amount of 
time to draw a polyline; it looked vaguely quadratic to me. Breaking the curve 
up into chunks of a few hundred points at a time made the drawing operation 
much faster (and the slight drawing imperfection wasn't noticeable). On the 
other hand, perhaps this problem has been fixed since then. :)


___

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

Please do not post admin requests or moderator comments to the list.
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: Decimation - NSBezierPath or something else?

2011-08-08 Thread wadeslists
> Does NSBezierPath do decimation as well as interpolation? I didn't find it in 
> the Class Reference.

It does whatever it needs to do in order to achieve "great" results, where 
"great" is in practical terms something like "an order of magnitude finer than 
pixel resolution".

Last I checked, it did not do any filtering - if you feed it a billion points 
that happen to represent a single line, it will perform as if for a billion 
points, not two.

> In my application, the math generates  hundreds of points for accuracy, for 
> every one that needs to be plotted to make a decent looking plot. Signal 
> processing theory says that you can't just throw away points, or you can 
> generate errors.

Indeed.  The question is how large those errors are compared to the pixel 
resolution.

> For example, I might generate 25,000 points and be happy to look at a 200 
> point plot. Throwing 25,000 points at NSBezierPath might swamp it, or at 
> least run very slowly.

NSBezierPath can handle millions of points in certain circumstances.  Where by 
"handle" I mean draw the path in a time on the order of hundreds of 
milliseconds.  That said, if you can pre-filter your path so that you don't 
provide unnecessary points (considering the output resolution) you might save 
yourself and your users a lot of waiting.

FWIW a trivial "is this point greater than 0.1 pixels away, in Cartesian 
distance" drop filter has worked well for me in the past, producing results 
that are essentially visually indistinguishable.  It has it's weakness, 
obviously, but tends to work well on "real world" data (i.e. data that isn't 
extremely high frequency and amplitude relative to the view size).  And when it 
doesn't work so effectively, users tend to prefer the visual accuracy over 
performance, since the difference in those cases can be so significant.  But 
your users may vary.

FYI if your line width is one pixel or lower NSBezierPath uses a much faster 
algorithm (as in, several orders of magnitude faster, in some circumstances).  
So keep that in mind.  Also keep in mind that the vast majority of its time, 
for many-point paths, is spent determining intersections.  If you can render 
your overall path in segments via multiple NSBezierPaths, that'll be much 
faster.

Also, NSBezierPath caches a lot of key info, so hold on to your references if 
you can reuse them.
___

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

Please do not post admin requests or moderator comments to the list.
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: Decimation - NSBezierPath or something else?

2011-08-08 Thread Graham Cox

On 09/08/2011, at 10:32 AM, Conrad Shultz wrote:

>>  Throwing 25,000 points at NSBezierPath might swamp 
>> it, or at least run very slowly.
> 
> The obligatory question: is this conjecture or have you found this to be
> the case?
> 
> I have some code that plots about 7500 points in a scalable, scrollable
> NSView using NSBezierPath (without attempting any fancy optimization)
> and I see absolutely no delay at all during either the initial render or
> subsequent transformations.


I can tell you that 25,000 points in a bezier path will make for slow drawing, 
though it also depends on your hardware of course.

NSBezierPath does not do automatic decimation or filtering - you have to do it 
yourself. For example I wrote a category on NSBezierPath to perform 
Douglas-Peucker simplification (which is a straightforward way to simplify a 
path without losing its essential qualities), and it was pretty strightforward. 
Unfortunately that code is commercial, so I can't share - an online search will 
reveal the method. D-P is old and simple but still a very good method - it's 
the "standard" way to simplify in GIS applications. There are variations on it 
that improve it somewhat.

--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: CFURLWriteDataAndPropertiesToResource as root?

2011-08-08 Thread Stephen Blinkhorn

On 8 Aug 2011, at 16:42, Sean McBride wrote:


On Mon, 8 Aug 2011 16:13:50 -0600, Stephen Blinkhorn said:

To be clear, you'd need to use ~/Library/App Support not the one  
in /

Library.


OK, no problem in Cocoa with the stringByExpandingTildeInPath: method
of NSString. More problematic for CFStringRef though. Is there an
acknowledged way of doing the equivalent with CFStringRefs? I
appreciate this is nolonger a Cocoa issue.


Actually, don't use stringByExpandingTildeInPath:.  Paths are  
deprecated, you should use NSURL or CFURL to reference file system  
objects.  Instead, do something like this:


NSFileManager* fileManager = [[NSFileManager alloc] init];
NSError* error = nil;
	NSURL* url = [fileManager  
URLForDirectory:NSApplicationSupportDirectory


 inDomain:NSUserDomainMask

appropriateForURL:nil

   create:YES

error:&error];

Not sure about at the CF level... you could use FSFindFolder() I  
guess.


[fileManager URLForDirectory:..] is 10.6+ only and since I'm  
supporting 10.4 through 10.7 I'm using FSFindFolder() for now and it's  
all working, even on Lion!


Thanks,
Stephen





--

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


Scaling the scroll wheel

2011-08-08 Thread tim lindner
I have a very wide NSView set as a document of an NSScrollView. When I
am zoomed in (by setting the cliprect bounds rectangle) swiping left and
right on my magic mouse scroll the expected amount.

But when zoomed out (when the bounds rect is nearly the same size of the
frame rect) left/right swiping is frustrating because of the small step
distance has almost no effect.

I'd like to scale the step distance used for wheel scrolling. How can I
do it?

-- 
tim lindner
tlind...@macmess.org  Bright
___

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

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


collapse/expand outline view row with animation

2011-08-08 Thread Martin Hewitson
Dear list,

I was wondering if anyone knows a way to get the animated collapsing/expanding 
of outline view rows programatically. Currently I'm using -collapseItem: and 
-expandItem: but the visual result doesn't have the animation that you get when 
clicking on the disclosure triangle. I'm trying to make double-clicking on 
group items expand or collapse.

Best wishes,

Martin
 

Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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

Please do not post admin requests or moderator comments to the list.
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: Decimation - NSBezierPath or something else?

2011-08-08 Thread N!K
Thank you all for your prompt and appropriate answers. 
NSBezier doesn't decimate although it does interpolate.
Lots and lots of points go slowly.

I could not believe that this is a new problem; it had to be recognizable and 
previously dealt with.
When a number of points occupy one pixel, something has to be done with them. 
With the old fashioned CRT, the points would bloom from repeated 
intensification at one location. Not knowing what that "something"  is in 
NSBezierPath or the rest of the path to today's flat panel screen seems risky.

I'll do the decimation. 
It's straightforward. 
It controls the process. 
It speeds things up. 
It might even be a little bit elegant.  :)


Nick___

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

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


Subclassing UIWebview a show-stopper?

2011-08-08 Thread arri
Hello,

After allot of writing test-cases, and googling for others'
experiences, i found that the most easy and straightforward way of
achieving what i want, is to simply subcass UIWebView and override
UIViews' - hitTest:withEvent method.
However, as everyone emphasize everywhere i look, the docs say i
"should" not subclass UIWebView.

Perhaps this is more about the english language than about software
development or Apple, but what does "should" exactlty mean in this
context.
Will Apple possibly reject the app if i use a UIWebView subclass?

Or does it mean how i've always understood the word "should" and i
could read the docs as such: "…there shouldn't be a need to
subclass…".
In other words: subclassing UIWebview will not result in a rejection.






thanks,
arri
___

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

Please do not post admin requests or moderator comments to the list.
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: Decimation - NSBezierPath or something else?

2011-08-08 Thread Graham Cox

On 09/08/2011, at 3:42 PM, N!K wrote:

> I could not believe that this is a new problem; it had to be recognizable and 
> previously dealt with.
> When a number of points occupy one pixel, something has to be done with them. 
> With the old fashioned CRT, the points would bloom from repeated 
> intensification at one location. Not knowing what that "something"  is in 
> NSBezierPath or the rest of the path to today's flat panel screen seems risky.


The thing to understand is that NSBezierPath doesn't know anything about 
pixels. It's an abstract data structure that describes a path, much as the 
mathematical concept of a 'line' represents something infinitely thin between 
two points in some arbitrary coordinate system.

Only when a path is rasterized is the path used to paint pixels. That isn't the 
job of NSBezierPath. Indeed, I would expect that the low level code that does 
this does take steps not to repeatedly draw the same pixel if the same path 
point ends up setting the same pixel. Also, bear in mind that the coordinate 
system that the path occupies is also completely abstract and resolution 
independent, so rasterizing to a printer context isn't going to be the same as 
rasterizing to the screen. Paths are scalable to any degree.

We don't typically have access to the low-level rasterizer code, we just leave 
it to Core Graphics to handle that. If you do want to do that yourself, you 
could use a third-party library such as Anti-Grain Geometry 
(http://www.antigrain.com/) to do it, where you could probably implement the 
simplifier at the rasterizer level. It's very doubtful that it would speed 
things up - the rasterizer is still going to have to iterate over all the 
path's points. Simplifying the path itself is well worthwhile, and can be done 
to an arbitrary precision (the DP algorithm for example lets you set a control 
value that affects the amount of simplification). But don't confuse doing this 
with optimising the path for rasterization.

--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: Subclassing UIWebview a show-stopper?

2011-08-08 Thread Dave DeLong
Hi Arri,

Subclassing UIWebView is probably not going to get your app rejected (though I 
have no insight in to the approval process).  However from a architecture 
point-of-view, it "smells" bad.  UIWebView is one of those views that's not 
intended to be subclassed.  Sure you can, since you can declare anything as 
your superclass, but I'd be highly surprised if the UIWebView authors are even 
expecting people to subclass it.  If they're not, then that could mean that 
there's logic in there that operates on the assumption of none of the methods 
being overridden.  There are certainly classes like that in all of the Cocoa 
(Touch) frameworks.

This sounds like one of the things that I'd only go ahead with after I've 
proven that every other idea presented isn't possible.

Dave

On Aug 8, 2011, at 10:51 PM, arri wrote:

> Hello,
> 
> After allot of writing test-cases, and googling for others'
> experiences, i found that the most easy and straightforward way of
> achieving what i want, is to simply subcass UIWebView and override
> UIViews' - hitTest:withEvent method.
> However, as everyone emphasize everywhere i look, the docs say i
> "should" not subclass UIWebView.
> 
> Perhaps this is more about the english language than about software
> development or Apple, but what does "should" exactlty mean in this
> context.
> Will Apple possibly reject the app if i use a UIWebView subclass?
> 
> Or does it mean how i've always understood the word "should" and i
> could read the docs as such: "…there shouldn't be a need to
> subclass…".
> In other words: subclassing UIWebview will not result in a rejection.
> 
> 
> 
> 
> 
> 
> thanks,
> arri
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com
> 
> This email sent to davedel...@me.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: CFURLWriteDataAndPropertiesToResource as root?

2011-08-08 Thread Chris Ridd

On 8 Aug 2011, at 16:02, Kyle Sluder wrote:

> On Aug 8, 2011, at 4:54 AM, Chris Ridd  wrote:
> 
>> 
>> Does OS X really support the sticky bit? Lion's  suggests "no", 
>> though this line could be read a couple of ways:
> 
> Yep, it's supported and used on directories. Don't think it's supported on 
> files, though.

I was assuming it was supported too, but the comment makes me less certain.

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


blocks and retaining CoreFoundation objects

2011-08-08 Thread Roland King
I have a slow image conversion which I want to throw onto a background thread 
using GCD. The actual method which does the conversion takes a CGImageRef and 
the code looks like this

-(void)convert:(CGImageRef)image withBlock:(ImageResizedBlock)callbackBlock
{
dispatch_async( dispatch_get_global_queue( 
DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
CGImageRef converted = [ self createConvertedImage:image ];
callbackBlock( converted );
CGImageRelease( converted );
} );
};

I quickly found that whereas NSObject(s) are retained by the block, 
CoreFoundation objects don't appear to be, so image can be, and usually is, 
released before the block runs, causing an exception. 

One way to fix this is to add a CFImageRetain() before the dispatch_async() and 
a CFImageRelease() inside the block at the same place converted is released, 
which works, but I for some reason don't like, probably because the retain is 
outside the block and the release is inside it and it seems odd to me. 

After a bit of googling I came across some posts which explained Block_Copy() 
would treat a variable adorned with __attribute__((NSObject)) similarly to 
NSObjects and retain them. So changing the method signature to this 

-(void)convert:(__attribute__((NSObject))CGImageRef)image 
withBlock:(ImageResizedBlock)callbackBlock

appears to do the right thing in my testing, the CGImageRef is CFRetain()ed 
when the block is enqueued and I assume CFRelease()d later. I prefer this 
syntax, as I find it self-documenting;

I can't find anywhere apart from blog posts and the block specification itself 
which says this works. Does anyone know if it's officially supported, for gcc 
and clang and something that apple is likely to support going forward into ARC 
etc. ___

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

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