Stealing settings from Mail.app

2010-05-28 Thread Chris Idou


I've got an app that needs to send out emails. I'm trying to import mail 
settings from Mail.app. For some reason my keychain has passwords for 
smtp.gmail.com, but not for smtp.me.com. Does anyone know where Mail.app stores 
other passwords? Or why my keychain has smtp.gmail.com passwords, but not 
passwords for other smtp servers I have setup in Mail.app?


 
___

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

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

2010-05-28 Thread Graham Cox
Thanks for the link Ken, though confusion still persists.

Seems to be saying don't use -setFlipped: unless you really know what you're 
doing. That concurs with your own advice about not using setFlipped unless 
you're locking focus on the image to get a flipped context for drawing. I'm 
not, since I generate my PDF in a context I create for the purpose, THEN add 
the image rep to an image.

So on the basis that I don't know what I'm doing, I've removed all calls to 
[NSImage setFlipped:] anywhere. In the PDF generating code quoted, I do pass 
YES for flipped because the object itself expects a flipped coordinate system, 
by which I simply mean that when I draw something  BELOW something else, it has 
a GREATER Y coordinate value.

Having no flipping anywhere now, unfortunately it's still all over the place.

First, if I ask the NSPDFImageRep created using the data generated below for 
its -PDFRepresentation, and write it to disk as a PDF file, it's now inverted. 
Objects are placed in the correct positions relative to one-another, but the 
entire image is upside-down, including any text.

So, I try setting the image to flipped when I add the single PDF image rep to 
it:

NSPDFImageRep* rep = [NSPDFImageRep imageRepWithData:[self 
pdf]];
[image addRepresentation:rep];
[image setFlipped:YES];

Now this image appears right-side up in NSImageView, but still writes an 
inverted PDF file and comes into Preview inverted. I can't really see how this 
is possible, since raw PDF data doesn't have any concept of 'flipped', does it? 
That surely means that the original PDF generation is wrong, but if I pass NO 
for flipped, not only is everything still upside-down but text is screwed as 
well, with each glyph individually inverted (which means that if the whole 
image is turned right-way up, any text is inverted).

I've read all the documentation on flipped coordinates and now the blog post as 
well. I'm afraid I'm just as confused as ever. What I need is a clear way 
through this mess. Turning off all flippedness seemed to be that but isn't. Now 
I have no idea what I need to flip and when.

--Graham



On 28/05/2010, at 3:20 PM, Ken Ferry wrote:

 On Thu, May 27, 2010 at 8:40 PM, Graham Cox graham@bigpond.com wrote:

NSSize size = [self bounds].size;
NSRect destRect = NSZeroRect;
 
destRect.size = size;
 
NSMutableData* pdfData = [NSMutableData data];
CGDataConsumerRef consumer = 
 CGDataConsumerCreateWithCFData((CFMutableDataRef) pdfData );
CGRect mediaBox = CGRectMake( 0, 0, size.width, size.height );
CGContextRef pdfContext = CGPDFContextCreate( consumer, mediaBox, 
 NULL );
CGDataConsumerRelease( consumer );
 
NSGraphicsContext* newGC = [NSGraphicsContext 
 graphicsContextWithGraphicsPort:pdfContext flipped:YES];
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:newGC];
 
CGPDFContextBeginPage( pdfContext, NULL );
 
[self drawContentInRect:destRect fromRect:NSZeroRect withStyle:nil];
 
CGPDFContextEndPage( pdfContext );
 
[NSGraphicsContext restoreGraphicsState];
 
CGPDFContextClose( pdfContext );
CGContextRelease( pdfContext );
 
return pdfData;
 
 
 Hi Graham,
 
 (First, for those following along, flipped images are deprecated in 10.6 
 along with -[NSImage setFlipped:].) 
 
 I agree, flipped images are confusing, and you can more or less think of them 
 as deprecated prior to 10.6 as well.  This weblog post does a nice job of 
 explaining what everything means and what to do about it: 
 http://www.noodlesoft.com/blog/2009/02/02/understanding-flipped-coordinate-systems/.
   This material is also covered in depth in the WWDC 2007 talk, Cocoa Drawing 
 Techniques.
 
 The only reason I can think of off the top of my head to call -setFlipped: on 
 an NSImage is if you plan to lockFocus on the image and you want the context 
 to be a flipped context during drawing.  This use case is addressed in 10.6 
 by the addition of -[NSImage lockFocusFlipped:] which gives you a flipped 
 context without doing anything to the internal state of the image.  
 
 -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: Generating PDF images (+followup question)

2010-05-28 Thread Ken Ferry
Did you read the explanation of flipped contexts vs flipped images, and how
to draw an image right side up into a flipped context?

Flipped contexts are not deprecated.

Do you have or can you obtain access to the 2007 WWDC videos? :-)

-Ken

On Thu, May 27, 2010 at 11:11 PM, Graham Cox graham@bigpond.com wrote:

 Thanks for the link Ken, though confusion still persists.

 Seems to be saying don't use -setFlipped: unless you really know what
 you're doing. That concurs with your own advice about not using setFlipped
 unless you're locking focus on the image to get a flipped context for
 drawing. I'm not, since I generate my PDF in a context I create for the
 purpose, THEN add the image rep to an image.

 So on the basis that I don't know what I'm doing, I've removed all calls to
 [NSImage setFlipped:] anywhere. In the PDF generating code quoted, I do pass
 YES for flipped because the object itself expects a flipped coordinate
 system, by which I simply mean that when I draw something  BELOW something
 else, it has a GREATER Y coordinate value.

 Having no flipping anywhere now, unfortunately it's still all over the
 place.

 First, if I ask the NSPDFImageRep created using the data generated below
 for its -PDFRepresentation, and write it to disk as a PDF file, it's now
 inverted. Objects are placed in the correct positions relative to
 one-another, but the entire image is upside-down, including any text.

 So, I try setting the image to flipped when I add the single PDF image rep
 to it:

NSPDFImageRep* rep = [NSPDFImageRep imageRepWithData:[self
 pdf]];
[image addRepresentation:rep];
[image setFlipped:YES];

 Now this image appears right-side up in NSImageView, but still writes an
 inverted PDF file and comes into Preview inverted. I can't really see how
 this is possible, since raw PDF data doesn't have any concept of 'flipped',
 does it? That surely means that the original PDF generation is wrong, but if
 I pass NO for flipped, not only is everything still upside-down but text is
 screwed as well, with each glyph individually inverted (which means that if
 the whole image is turned right-way up, any text is inverted).

 I've read all the documentation on flipped coordinates and now the blog
 post as well. I'm afraid I'm just as confused as ever. What I need is a
 clear way through this mess. Turning off all flippedness seemed to be that
 but isn't. Now I have no idea what I need to flip and when.

 --Graham



 On 28/05/2010, at 3:20 PM, Ken Ferry wrote:

  On Thu, May 27, 2010 at 8:40 PM, Graham Cox graham@bigpond.com
 wrote:

 NSSize size = [self bounds].size;
 NSRect destRect = NSZeroRect;
 
 destRect.size = size;
 
 NSMutableData* pdfData = [NSMutableData data];
 CGDataConsumerRef consumer =
 CGDataConsumerCreateWithCFData((CFMutableDataRef) pdfData );
 CGRect mediaBox = CGRectMake( 0, 0, size.width, size.height );
 CGContextRef pdfContext = CGPDFContextCreate( consumer, mediaBox,
 NULL );
 CGDataConsumerRelease( consumer );
 
 NSGraphicsContext* newGC = [NSGraphicsContext
 graphicsContextWithGraphicsPort:pdfContext flipped:YES];
 [NSGraphicsContext saveGraphicsState];
 [NSGraphicsContext setCurrentContext:newGC];
 
 CGPDFContextBeginPage( pdfContext, NULL );
 
 [self drawContentInRect:destRect fromRect:NSZeroRect
 withStyle:nil];
 
 CGPDFContextEndPage( pdfContext );
 
 [NSGraphicsContext restoreGraphicsState];
 
 CGPDFContextClose( pdfContext );
 CGContextRelease( pdfContext );
 
 return pdfData;
 
 
  Hi Graham,
 
  (First, for those following along, flipped images are deprecated in 10.6
 along with -[NSImage setFlipped:].)
 
  I agree, flipped images are confusing, and you can more or less think of
 them as deprecated prior to 10.6 as well.  This weblog post does a nice job
 of explaining what everything means and what to do about it: 
 http://www.noodlesoft.com/blog/2009/02/02/understanding-flipped-coordinate-systems/.
  This material is also covered in depth in the WWDC 2007 talk, Cocoa Drawing
 Techniques.
 
  The only reason I can think of off the top of my head to call
 -setFlipped: on an NSImage is if you plan to lockFocus on the image and you
 want the context to be a flipped context during drawing.  This use case is
 addressed in 10.6 by the addition of -[NSImage lockFocusFlipped:] which
 gives you a flipped context without doing anything to the internal state of
 the image.
 
  -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 

Re: Generating PDF images (+followup question)

2010-05-28 Thread Ken Ferry
(Also, again for others following along, on 10.6 you just pass YES for
respectFlipped in -[NSImage
drawInRect:fromRect:operation:fraction:respectFlipped:hints:].  The
implementation is quite similar to the method Paul gives in the post.)

On Thu, May 27, 2010 at 11:17 PM, Ken Ferry kenfe...@gmail.com wrote:

 Did you read the explanation of flipped contexts vs flipped images, and how
 to draw an image right side up into a flipped context?

 Flipped contexts are not deprecated.

 Do you have or can you obtain access to the 2007 WWDC videos? :-)

 -Ken


 On Thu, May 27, 2010 at 11:11 PM, Graham Cox graham@bigpond.comwrote:

 Thanks for the link Ken, though confusion still persists.

 Seems to be saying don't use -setFlipped: unless you really know what
 you're doing. That concurs with your own advice about not using setFlipped
 unless you're locking focus on the image to get a flipped context for
 drawing. I'm not, since I generate my PDF in a context I create for the
 purpose, THEN add the image rep to an image.

 So on the basis that I don't know what I'm doing, I've removed all calls
 to [NSImage setFlipped:] anywhere. In the PDF generating code quoted, I do
 pass YES for flipped because the object itself expects a flipped coordinate
 system, by which I simply mean that when I draw something  BELOW something
 else, it has a GREATER Y coordinate value.

 Having no flipping anywhere now, unfortunately it's still all over the
 place.

 First, if I ask the NSPDFImageRep created using the data generated below
 for its -PDFRepresentation, and write it to disk as a PDF file, it's now
 inverted. Objects are placed in the correct positions relative to
 one-another, but the entire image is upside-down, including any text.

 So, I try setting the image to flipped when I add the single PDF image rep
 to it:

NSPDFImageRep* rep = [NSPDFImageRep imageRepWithData:[self
 pdf]];
[image addRepresentation:rep];
[image setFlipped:YES];

 Now this image appears right-side up in NSImageView, but still writes an
 inverted PDF file and comes into Preview inverted. I can't really see how
 this is possible, since raw PDF data doesn't have any concept of 'flipped',
 does it? That surely means that the original PDF generation is wrong, but if
 I pass NO for flipped, not only is everything still upside-down but text is
 screwed as well, with each glyph individually inverted (which means that if
 the whole image is turned right-way up, any text is inverted).

 I've read all the documentation on flipped coordinates and now the blog
 post as well. I'm afraid I'm just as confused as ever. What I need is a
 clear way through this mess. Turning off all flippedness seemed to be that
 but isn't. Now I have no idea what I need to flip and when.

 --Graham



 On 28/05/2010, at 3:20 PM, Ken Ferry wrote:

  On Thu, May 27, 2010 at 8:40 PM, Graham Cox graham@bigpond.com
 wrote:

 NSSize size = [self bounds].size;
 NSRect destRect = NSZeroRect;
 
 destRect.size = size;
 
 NSMutableData* pdfData = [NSMutableData data];
 CGDataConsumerRef consumer =
 CGDataConsumerCreateWithCFData((CFMutableDataRef) pdfData );
 CGRect mediaBox = CGRectMake( 0, 0, size.width, size.height );
 CGContextRef pdfContext = CGPDFContextCreate( consumer,
 mediaBox, NULL );
 CGDataConsumerRelease( consumer );
 
 NSGraphicsContext* newGC = [NSGraphicsContext
 graphicsContextWithGraphicsPort:pdfContext flipped:YES];
 [NSGraphicsContext saveGraphicsState];
 [NSGraphicsContext setCurrentContext:newGC];
 
 CGPDFContextBeginPage( pdfContext, NULL );
 
 [self drawContentInRect:destRect fromRect:NSZeroRect
 withStyle:nil];
 
 CGPDFContextEndPage( pdfContext );
 
 [NSGraphicsContext restoreGraphicsState];
 
 CGPDFContextClose( pdfContext );
 CGContextRelease( pdfContext );
 
 return pdfData;
 
 
  Hi Graham,
 
  (First, for those following along, flipped images are deprecated in 10.6
 along with -[NSImage setFlipped:].)
 
  I agree, flipped images are confusing, and you can more or less think of
 them as deprecated prior to 10.6 as well.  This weblog post does a nice job
 of explaining what everything means and what to do about it: 
 http://www.noodlesoft.com/blog/2009/02/02/understanding-flipped-coordinate-systems/.
  This material is also covered in depth in the WWDC 2007 talk, Cocoa Drawing
 Techniques.
 
  The only reason I can think of off the top of my head to call
 -setFlipped: on an NSImage is if you plan to lockFocus on the image and you
 want the context to be a flipped context during drawing.  This use case is
 addressed in 10.6 by the addition of -[NSImage lockFocusFlipped:] which
 gives you a flipped context without doing anything to the internal state of
 the image.
 
  -Ken
  Cocoa Frameworks



___

Cocoa-dev mailing list 

six things I wasn't able to do with Cocoa

2010-05-28 Thread Bill Appleton
hi all,


I just ported a huge code base to Cocoa, Core Graphics, Core Audio, and
QuickTime. Basically I had a good experience, but there were some things i
noticed that i couldn't do easily in Cocoa or any other 64 bit OSX API.

So just in case anyone knows a way to do the things listed below please let
me know:


*1) I can't hide a file, or test if a file is hidden*

I had to resort to FSGetCatalogInfo -- there is no way to do it through
NSFileManager, etc. Right?


*2)** **I **can't **get the current caret blink rate in milliseconds*

I used to call GetCaretTime, but now I just use 500 milliseconds. Eeek!
Where is the current blink rate? Please don't tell me I don't need it, we
implement our own scripting engine, etc.


*3)** **I **can't get t**he right dimensions for a QuickTime movie or poster
*

I used to call GetMovieBox, so I tried using [QTMovie posterImage] but the
NSImage reported a width and height of 100, and then my movie poster was
really pixelated. How do I get a decent looking movie poster? How do I get
the original dimensions for movie playback?


*4)** **I **can't call the printing code*

I know, the printing code calls me. But other platforms don't work like
this. I eventually used Core Printing and the Cocoa dialogs by sub-classing
and faking out NSPrintPanel. Is there a better way?


*5)** **I **can't create a simple list*

I did it the only way I could -- with a table that has one column, etc. Man
that was painful for a simple list. Is there a better way?


*6)** **I **can't get the height of some wrapped text*

I had to use the layout manager and some major rocket science to get this to
work right. I'm not saying Text Edit was great, but at least it knows how
tall the text field is.




Thanks!


Bill Appleton
___

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

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

2010-05-28 Thread Graham Cox

On 28/05/2010, at 4:17 PM, Ken Ferry wrote:

 Did you read the explanation of flipped contexts vs flipped images, and how 
 to draw an image right side up into a flipped context?
 
 Flipped contexts are not deprecated.

I understand that contexts can (still) be flipped.

Let's break this down a bit, since I'm fighting two problems simultaneously 
here. First, PDF File generation.

Using the code I quoted, I generate PDF data in a flipped context. The flipped 
context matches the coordinate system that drawn objects expect. As such, 
objects and text are all positioned in the correct relative locations.

If I write the PDF data immediately to a file, no NSImage or rep involved, 
result is an upside down PDF file when it's opened in Preview.

If I generate the PDF data in a non-flipped context, the PDF File is still 
upside down, with the added problem that text glyphs are inverted individually.

So at no point have I done anything with this image like draw it anywhere. How 
can it even be possible for PDF data in a file to be inverted? The problem 
appears to be with the PDF generation, so what's wrong there?


 Do you have or can you obtain access to the 2007 WWDC videos? :-)
 


Not sure - will try to find them. So far a search on ADC brings up just one 
result and it's in Japanese...

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


Where is zlib located?

2010-05-28 Thread Tito Ciuro
Hello,

I'm trying to incorporate zip-framework 
(http://code.google.com/p/zip-framework/) in my project. When I compile the 
sources in Xcode I see this error:

 inflate, referenced from:
 -readFromEntry:buffer:length: in ZipArchive.o
 
 inflateInit2, referenced from: -entryNamed: in ZipArchive.o
 
 ld: symbol(s) not found collect2: ld returned 1 exit status

The sources import zlib.h, so I guess I need to add zlib to my project, but I 
cannot find it. Where is it located?

Thanks,

-- Tito
___

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

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

2010-05-28 Thread Roland King
libz.dylib

it's the last thing listed in the list if I go 'add framework' - 'existing 
frameworks'. 


On 28-May-2010, at 2:40 PM, Tito Ciuro wrote:

 Hello,
 
 I'm trying to incorporate zip-framework 
 (http://code.google.com/p/zip-framework/) in my project. When I compile the 
 sources in Xcode I see this error:
 
 inflate, referenced from:
 -readFromEntry:buffer:length: in ZipArchive.o
 
 inflateInit2, referenced from: -entryNamed: in ZipArchive.o
 
 ld: symbol(s) not found collect2: ld returned 1 exit status
 
 The sources import zlib.h, so I guess I need to add zlib to my project, but I 
 cannot find it. Where is it located?
 
 Thanks,
 
 -- Tito
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org
 
 This email sent to r...@rols.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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Ken Ferry
Hi Bill,

Thanks for the postmortem.  Would you mind filing bugs for the items you
think are too difficult?

On Thu, May 27, 2010 at 12:43 PM, Bill Appleton 
billapple...@dreamfactory.com wrote:

 hi all,


 I just ported a huge code base to Cocoa, Core Graphics, Core Audio, and
 QuickTime. Basically I had a good experience, but there were some things i
 noticed that i couldn't do easily in Cocoa or any other 64 bit OSX API.

 So just in case anyone knows a way to do the things listed below please let
 me know:


 *1) I can't hide a file, or test if a file is hidden*

 I had to resort to FSGetCatalogInfo -- there is no way to do it through
 NSFileManager, etc. Right?


These two are pretty easy in 10.6.  -[NSURL getResourceValue:forKey:error:]
/ -[NSURL setResourceValue:forKey:error:] with NSURLIsHiddenKey.  Cocoa is
trying to standardize on URLs rather than paths.


 *2)** **I **can't **get the current caret blink rate in milliseconds*

 I used to call GetCaretTime, but now I just use 500 milliseconds. Eeek!
 Where is the current blink rate? Please don't tell me I don't need it, we
 implement our own scripting engine, etc.


The actual default rate is once per 0.56 seconds.

*3)** **I **can't get t**he right dimensions for a QuickTime movie or poster
 *

 I used to call GetMovieBox, so I tried using [QTMovie posterImage] but the
 NSImage reported a width and height of 100, and then my movie poster was
 really pixelated. How do I get a decent looking movie poster? How do I get
 the original dimensions for movie playback?


Perhaps QTMovieNaturalSizeAttribute ? I'm not familiar with this API, but
there are a few size-related attributes.


 *4)** **I **can't call the printing code*

 I know, the printing code calls me. But other platforms don't work like
 this. I eventually used Core Printing and the Cocoa dialogs by sub-classing
 and faking out NSPrintPanel. Is there a better way?


I don't understand this one.  
http://developer.apple.com/mac/library/documentation/cocoa/conceptual/Printing/Tasks/CreatingPrintJob.html
.

*5)** **I **can't create a simple list*

 I did it the only way I could -- with a table that has one column, etc. Man
 that was painful for a simple list. Is there a better way?


I'm not sure how much of NSTableView's behavior you want, but it's possible
you'd find NSCollectionView to be simpler.


 *6)** **I **can't get the height of some wrapped text*

 I had to use the layout manager and some major rocket science to get this
 to
 work right. I'm not saying Text Edit was great, but at least it knows how
 tall the text field is.


NSLayoutManager might be appropriate, but there's also
-[NSString boundingRectWithSize:options:attributes:].  You might find 
http://lists.apple.com/archives/Cocoa-dev/2008/Jan/msg00814.html helpful.

-Ken





 Thanks!


 Bill Appleton
 ___

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

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

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

 This email sent to kenfe...@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: Generating PDF images (+followup question)

2010-05-28 Thread Stephen J. Butler
On Fri, May 28, 2010 at 1:36 AM, Graham Cox graham@bigpond.com wrote:
 I understand that contexts can (still) be flipped.

 Let's break this down a bit, since I'm fighting two problems simultaneously 
 here. First, PDF File generation.

 Using the code I quoted, I generate PDF data in a flipped context. The 
 flipped context matches the coordinate system that drawn objects expect. As 
 such, objects and text are all positioned in the correct relative locations.

 If I write the PDF data immediately to a file, no NSImage or rep involved, 
 result is an upside down PDF file when it's opened in Preview.

 If I generate the PDF data in a non-flipped context, the PDF File is still 
 upside down, with the added problem that text glyphs are inverted 
 individually.

 So at no point have I done anything with this image like draw it anywhere. 
 How can it even be possible for PDF data in a file to be inverted? The 
 problem appears to be with the PDF generation, so what's wrong there?

My understanding of this isn't the best, but here's how I see it:

The idea of flipped/not-flipped is a Cocoa idea. But CGContexts
aren't Cocoa and they don't have the notion of being flipped or not.
That's exactly why the +[NSGraphicsContext
graphicsContextWithGraphicsPort:flipped:] call has to ask if the CG
context it is getting is flipped or not! If the CG context knew,
NSGraphicsContext could just ask it.

So, your view is flipped and all your drawing operations assume a
flipped context. How do we get there for PDFs? Simple... we apply a
Current Transformation Matrix (CTM) that flips the CG context!
Something like this should work:

// Move the origin to the top of the context
CGContextTranslateCTM( pdfContext, 0.0, size.height );
// Now flip the y-axis so that it increases downwards
CGContextScaleCTM( pdfContext, 1.0, -1.0 );

And now you would pass flipped:YES to +[NSGraphicsContext
graphicsContextWithGraphicsPort:flipped:] because we just flipped it!

Basically, you were almost there. You got a perfect PDF file, just
upside down. Another way to look at all of this is what CTM do I need
to apply to get everything right side up? The answer is, flip the
y-axis over y=0 (the x-axis) and add the height.
___

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

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

2010-05-28 Thread Graham Cox
Hallelujah!!!

Thanks Stephen, that's the piece of the puzzle I was missing. I was assuming 
(or misinterpreting) that passing flipped:YES for the NSGraphicsContext 
ACTUALLY FLIPPED the context, not just informed it that the context had been 
flipped.

I found I had to set the CTM after the CGPDFContextBeginPage - looks like that 
might be resetting it, but basically, it works, I now get a right-way up PDF 
file.

Now I know my source data really is right-side up, I can figure out the second 
part which is making sure images that embody it DRAW right-side up.

thanks again, greatly relieved!

--Graham



On 28/05/2010, at 5:11 PM, Stephen J. Butler wrote:

 CGContextTranslateCTM( pdfContext, 0.0, size.height );
 // Now flip the y-axis so that it increases downwards
 CGContextScaleCTM( pdfContext, 1.0, -1.0 );

___

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

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

2010-05-28 Thread Ken Ferry
Heh.  Okay, glad that made sense, but as discussed in all the other
resources, yes, context flippedness is a piece of _metadata_ orthogonal from
the CTM.  You may consult it to get the high level notion of which way
should be considered up.

On Fri, May 28, 2010 at 12:22 AM, Graham Cox graham@bigpond.com wrote:

 Hallelujah!!!

 Thanks Stephen, that's the piece of the puzzle I was missing. I was
 assuming (or misinterpreting) that passing flipped:YES for the
 NSGraphicsContext ACTUALLY FLIPPED the context, not just informed it that
 the context had been flipped.

 I found I had to set the CTM after the CGPDFContextBeginPage - looks like
 that might be resetting it, but basically, it works, I now get a right-way
 up PDF file.

 Now I know my source data really is right-side up, I can figure out the
 second part which is making sure images that embody it DRAW right-side up.

 thanks again, greatly relieved!

 --Graham



 On 28/05/2010, at 5:11 PM, Stephen J. Butler wrote:

  CGContextTranslateCTM( pdfContext, 0.0, size.height );
  // Now flip the y-axis so that it increases downwards
  CGContextScaleCTM( pdfContext, 1.0, -1.0 );

 ___

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

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

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

 This email sent to kenfe...@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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Alastair Houghton
On 27 May 2010, at 20:43, Bill Appleton wrote:

 *1) I can't hide a file, or test if a file is hidden*
 
 I had to resort to FSGetCatalogInfo -- there is no way to do it through
 NSFileManager, etc. Right?

chflags(), with UF_HIDDEN?  And stat() to read the same?

I don't think FSGet/SetCatalogInfo is deprecated on 64-bit though, so you could 
just use that if you're more comfortable doing it that way.

 *5)** **I **can't create a simple list*
 
 I did it the only way I could -- with a table that has one column, etc. Man
 that was painful for a simple list. Is there a better way?

It's not *that* painful.  In fact, if you use bindings and an 
NSArrayController, it's pretty much done for you.

 *6)** **I **can't get the height of some wrapped text*
 
 I had to use the layout manager and some major rocket science to get this to
 work right. I'm not saying Text Edit was great, but at least it knows how
 tall the text field is.

NSAttributedString's -boundingRectWithSize:options: is probably helpful for 
this, depending on exactly what size you're after (there's more than one 
possible set of dimensions you might care about, depending on exactly what 
you're doing).

Cocoa Text is, I think, a bit daunting when you first encounter it; it's very 
powerful and exposes a great deal of the underlying machinery behind text 
rendering, but the flip-side of that is that it's a huge API and that alone can 
be off-putting.  I think once you get over that, it's actually pretty easy to 
use---and if you're worried that it all seems a bit heavyweight to just draw 
a string, remember that most of what it does is actually necessary to get the 
string on the display, so all of the simpler APIs you might have used 
previously were still doing all of the same work (give or take).

Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


Re: six things I wasn't able to do with Cocoa

2010-05-28 Thread Chaitanya Pandit
 
 *3)** **I **can't get t**he right dimensions for a QuickTime movie or poster
 *
 

NSSize movieSize =  [[movieObject currentFrameImage] size];

 I used to call GetMovieBox, so I tried using [QTMovie posterImage] but the
 NSImage reported a width and height of 100, and then my movie poster was
 really pixelated. How do I get a decent looking movie poster? How do I get
 the original dimensions for movie playback?
 
 
 *4)** **I **can't call the printing code*
 
 I know, the printing code calls me. But other platforms don't work like
 this. I eventually used Core Printing and the Cocoa dialogs by sub-classing
 and faking out NSPrintPanel. Is there a better way?
 
 
 *5)** **I **can't create a simple list*
 
 I did it the only way I could -- with a table that has one column, etc. Man
 that was painful for a simple list. Is there a better way?
 
 
 *6)** **I **can't get the height of some wrapped text*
 
 I had to use the layout manager and some major rocket science to get this to
 work right. I'm not saying Text Edit was great, but at least it knows how
 tall the text field is.
 
 
 
 
 Thanks!
 
 
 Bill Appleton
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/chaitanya%40expersis.com
 
 This email sent to chaita...@expersis.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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Tony Romano
To see if a file is hidden, I use on the URL(NSURL Class) for the file, 
resourceValuesForKeys and pass in the array of properties you are looking for.  
In the case of  a hidden file, use NSURLIsHiddenKey.
You should be able to make a file hidden as well by using the set counter part. 
 Check out the NSURL class.

-Tony

On May 28, 2010, at 1:10 AM, Alastair Houghton wrote:

 On 27 May 2010, at 20:43, Bill Appleton wrote:
 
 *1) I can't hide a file, or test if a file is hidden*
 
 I had to resort to FSGetCatalogInfo -- there is no way to do it through
 NSFileManager, etc. Right?
 
 chflags(), with UF_HIDDEN?  And stat() to read the same?
 
 I don't think FSGet/SetCatalogInfo is deprecated on 64-bit though, so you 
 could just use that if you're more comfortable doing it that way.
 
 *5)** **I **can't create a simple list*
 
 I did it the only way I could -- with a table that has one column, etc. Man
 that was painful for a simple list. Is there a better way?
 
 It's not *that* painful.  In fact, if you use bindings and an 
 NSArrayController, it's pretty much done for you.
 
 *6)** **I **can't get the height of some wrapped text*
 
 I had to use the layout manager and some major rocket science to get this to
 work right. I'm not saying Text Edit was great, but at least it knows how
 tall the text field is.
 
 NSAttributedString's -boundingRectWithSize:options: is probably helpful for 
 this, depending on exactly what size you're after (there's more than one 
 possible set of dimensions you might care about, depending on exactly what 
 you're doing).
 
 Cocoa Text is, I think, a bit daunting when you first encounter it; it's very 
 powerful and exposes a great deal of the underlying machinery behind text 
 rendering, but the flip-side of that is that it's a huge API and that alone 
 can be off-putting.  I think once you get over that, it's actually pretty 
 easy to use---and if you're worried that it all seems a bit heavyweight to 
 just draw a string, remember that most of what it does is actually 
 necessary to get the string on the display, so all of the simpler APIs you 
 might have used previously were still doing all of the same work (give or 
 take).
 
 Kind regards,
 
 Alastair.
 
 --
 http://alastairs-place.net
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/tonyrom%40hotmail.com
 
 This email sent to tony...@hotmail.com
 

-Tony

___

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

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


NSURLConnection weirdiness

2010-05-28 Thread Nava Carmon
Hi,

I'm experiencing a weird problem and i wonder if anybody else has noticed this: 
I'm using NSURLConnection as it appears in apple's examples to get xml files 
from a certain server (standard http get) - pretty straight forward. And most 
of time it works, but sometimes it's just stuck after initialing and don't get 
into connection's delegate methods. I'm working with WiFi  3G and the same 
server all the time. When it comes to didFailWithError i see that mostly it was 
a timeout error. When I enter same link in Safari it takes a second to bring 
data. And after another trial I can access the link. What might be the reason 
for such a weird behavior? How can I improve it? What is the role of cache 
policy with NSURLConnection?

Thanks,

Nava


Nava Carmon
ncar...@mac.com

Think good and it will be good!

___

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

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


Notification of file system modification arrives too early?

2010-05-28 Thread Antonio Nunes
Hi,

My app is set to observe a folder for changes to its contents (using UKKQueue. 
Thanks Uli! :-)). When files are dropped into the folder the app is notified 
and processes the files. This works well, except for one catch: sometimes we 
receive the notification and spawn the worker thread, and trying to load the 
file fails ( [[PDFDocument alloc] initWithURL:sourceURL] returns nil). This 
seems to happen predominantly with large files. I get the impression the 
notification happens as soon as the file transfer into the watched directory 
begins, and my worker thread is ready and starts loading the file before it has 
been fully transferred. Hence the failure to create a PDFDocument from the file.

Is there a way to check whether the file has been fully transferred, or, even 
better, to get notified only when the file transfer has been completed?

António

---
What you have inside you expresses itself through both your
choice of words and the level of energy you assign to them.
The more healed, whole and connected you feel inside,
the more healing your words will be.

--Rita Goswami
---


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 file system modification arrives too early?

2010-05-28 Thread Uli Kusterer
On May 28, 2010, at 12:05 PM, Antonio Nunes wrote:
 My app is set to observe a folder for changes to its contents (...) I get the 
 impression the notification happens as soon as the file transfer into the 
 watched directory begins, and my worker thread is ready and starts loading 
 the file before it has been fully transferred. Hence the failure to create a 
 PDFDocument from the file.

 Yes. A KQueue only tells you when a *change* happens, i.e. an individual write 
operation.

 Is there a way to check whether the file has been fully transferred, or, even 
 better, to get notified only when the file transfer has been completed?

 The heuristic most people use is to wait a little time (a few seconds is 
usually enough) and only start processing a file if a new write notification 
hasn't arrived in the meantime. I usually use my UKPushbackMessenger for that 
purpose (see 
http://github.com/uliwitness/UliKit/blob/master/UKPushbackMessenger.h and 
http://github.com/uliwitness/UliKit/blob/master/UKPushbackMessenger.m).

-- Uli Kusterer
The Witnesses of TeachText are everywhere...



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 file system modification arrives too early?

2010-05-28 Thread Antonio Nunes
On 28 May 2010, at 11:30, Uli Kusterer wrote:

 The heuristic most people use is to wait a little time (a few seconds is 
 usually enough) and only start processing a file if a new write notification 
 hasn't arrived in the meantime. I usually use my UKPushbackMessenger for that 
 purpose (see 
 http://github.com/uliwitness/UliKit/blob/master/UKPushbackMessenger.h 
 andhttp://github.com/uliwitness/UliKit/blob/master/UKPushbackMessenger.m).

Gruezi Uli,

I was hoping the system would provide something better for this. Looks like an 
enhancement request is in order.

Since PDF documents can potentially be huge, and I need to keep performance as 
good as possible, I need something more robust than waiting a few seconds. I am 
now experimenting with trying to read in a PDFDocument from the url, and not 
spawn the worker thread until this succeeds. Initial results look promising. 
The thread that sets up the task waits until it can successfully read in a 
PDFDocument from the URL, then releases the document and launches the task. I 
find this a bit of a hack, but if it works, it works, and I think this provides 
tighter performance than waiting for a set number of seconds (which may in 
extreme cases not to be long enough anyway).

Best,
António

---
Don't believe everything you think
---




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 file system modification arrives too early?

2010-05-28 Thread Antonio Nunes
On 28 May 2010, at 11:41, Antonio Nunes wrote:

 I was hoping the system would provide something better for this. Looks like 
 an enhancement request is in order.

Request filed. Bug ID# 8038793: Need notification of file system modification 
after completion of the operation.

Cheers,
António


There is nothing as strong as real gentleness, and
there is nothing as gentle as real strength.





___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 file system modification arrives too early?

2010-05-28 Thread Uli Kusterer
On May 28, 2010, at 12:53 PM, Antonio Nunes wrote:
 On 28 May 2010, at 11:41, Antonio Nunes wrote:
 I was hoping the system would provide something better for this. Looks like 
 an enhancement request is in order.
 
 Request filed. Bug ID# 8038793: Need notification of file system 
 modification after completion of the operation.

Are you doing this for Finder-originated copying only? In this case, you could 
probably look at the file's OSType/creator. I believe they get set to some 
special busy-values during copying, so if you get a write notification and 
your file has that type, you *know* it's not intended to be processed yet.

-- Uli Kusterer
The Witnesses of TeachText are everywhere...



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 file system modification arrives too early?

2010-05-28 Thread Jean-Daniel Dupas

Le 28 mai 2010 à 12:53, Antonio Nunes a écrit :

 On 28 May 2010, at 11:41, Antonio Nunes wrote:
 
 I was hoping the system would provide something better for this. Looks like 
 an enhancement request is in order.
 
 Request filed. Bug ID# 8038793: Need notification of file system 
 modification after completion of the operation.
 

I hope you properly defined what you mean by operation, because on a file 
system point of view, this is already what kqueue does.
A copy is not one operation but a bunch of operations (open, lots of write, 
close, set attrs, set xattrs, …), and kqueue already notify you each time an 
operation is done.

-- 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: isKindofClass with NSData and NSKeyUnarchiver

2010-05-28 Thread Uli Kusterer
On May 28, 2010, at 2:25 AM, Philip Vallone wrote:
 This is a relative question, which depends on how the data is coming and 
 going. My question comes from the following situation. Suppose I have a 
 GKSession that is passing information via Bluetooth. The sender can send any 
 type of information (NSString, UIImage etc...). The receiver needs to know 
 how to handle this data. If there is a better way... Then how?

Haven't used GameKit yet, but programs rarely need to send *raw* data. What 
they usually need to send is some higher-level concept, in your case that could 
be a game command. So what you'd usually do is create some NSObject subclass 
that encapsulates the general API of a command. You'd in turn create separate 
subclasses for the individual commands. NSArchiver already knows how to 
recreate that object, so you'd then just call an -apply method the base class 
declares but the subclasses implement, and you'd have everything working 
automatically.

The subclass would then take care of unarchiving the expected image resp. 
string and do with it whatever needs to be done (e.g. update the player avatar 
with that image, or display the given message from the other user, or apply the 
movements of a remote user to the local game state.

(Of course, there are security/robustness considerations with any network 
communication to avoid trickery, or just keep cheaters from pretending their 
player had moved by 6 miles in a split-second and thus wasn't shot, but that's 
not part of this discussion)

-- Uli Kusterer
The Witnesses of TeachText are everywhere...



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 file system modification arrives too early?

2010-05-28 Thread Antonio Nunes
On 28 May 2010, at 12:15, Jean-Daniel Dupas wrote:

 I hope you properly defined what you mean by operation, because on a file 
 system point of view, this is already what kqueue does.
 A copy is not one operation but a bunch of operations (open, lots of write, 
 close, set attrs, set xattrs, …), and kqueue already notify you each time an 
 operation is done.

Hmm, I see, better have another good look at the notifications the I can choose 
to listen to. Thanks. Looks like an attribute change notification and a size 
increase notification might be useful candidates. I'll play with them and see 
what results I can get.

António


A merry heart does good like medicine



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 file system modification arrives too early?

2010-05-28 Thread Antonio Nunes
On 28 May 2010, at 12:07, Uli Kusterer wrote:

 Are you doing this for Finder-originated copying only? In this case, you 
 could probably look at the file's OSType/creator. I believe they get set to 
 some special busy-values during copying, so if you get a write notification 
 and your file has that type, you *know* it's not intended to be processed yet.

I expect many of the files will arrive in the watched folder either through 
user manipulation in the Finder or through scripts/automation. I don't think I 
can assume only Finder-originated copying.

António

-
Perfume is the forgiveness
that the trampled flower casts
upon the heel that crushes it.
-



___

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

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

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

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


Re: isKindofClass with NSData and NSKeyUnarchiver

2010-05-28 Thread Sherm Pendley
On Thu, May 27, 2010 at 8:25 PM, Philip Vallone
philip.vall...@verizon.net wrote:

 This is a relative question, which depends on how the data is coming and 
 going. My question comes from the following situation. Suppose I have a 
 GKSession that is passing information via Bluetooth. The sender can send any 
 type of information (NSString, UIImage etc...). The receiver needs to know 
 how to handle this data. If there is a better way... Then how?

 I appreciate the feed back and help,

I would let the sent objects handle the work themselves. A switch or
series of ifs based on class is an OOP anti-pattern. Polymorphism is
often a better alternative, and Objective-C's ability to add a
category to any class makes it easy to implement. So,  I would extend
NSString, UIImage, etc. - whatever types can be sent - by adding a new
method mySuperDuperMethod (for example).

Then, what you're left with in the receiver class is simply:

if ([obj respondsToSelector(@selector(mySuperDuperMethod))]) {
[obj performSelector:@selector(mySuperDuperMethod)];
}

If the ability of a sent object to implement mySuperDuperMethod is
critical, you could add an else block to log and/or assert any such
failures.

sherm--

-- 
Cocoa programming in Perl:
http://www.camelbones.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: Where is zlib located?

2010-05-28 Thread Tito Ciuro
Thanks a lot Roland!

-- Tito

On May 28, 2010, at 8:51 AM, Roland King wrote:

 libz.dylib
 
 it's the last thing listed in the list if I go 'add framework' - 'existing 
 frameworks'. 
 
 
 On 28-May-2010, at 2:40 PM, Tito Ciuro wrote:
 
 Hello,
 
 I'm trying to incorporate zip-framework 
 (http://code.google.com/p/zip-framework/) in my project. When I compile the 
 sources in Xcode I see this error:
 
 inflate, referenced from:
 -readFromEntry:buffer:length: in ZipArchive.o
 
 inflateInit2, referenced from: -entryNamed: in ZipArchive.o
 
 ld: symbol(s) not found collect2: ld returned 1 exit status
 
 The sources import zlib.h, so I guess I need to add zlib to my project, but 
 I cannot find it. Where is it located?
 
 Thanks,
 
 -- Tito
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org
 
 This email sent to r...@rols.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


NSFileManager 'attributesOfItemAtPath:error:' does not traverse a link?

2010-05-28 Thread Tito Ciuro
Hello,

I'm trying to replace the following deprecated NSFileManager method:

 /* attributesOfItemAtPath:error: returns an NSDictionary of key/value pairs 
 containing the attributes of the item (file, directory, symlink, etc.) at the 
 path in question. If this method returns 'nil', an NSError will be returned 
 by reference in the 'error' parameter. This method does not traverse a 
 terminal symlink.
  
 This method replaces fileAttributesAtPath:traverseLink:.
  */
 - (NSDictionary *)attributesOfItemAtPath:(NSString *)path error:(NSError 
 **)error;


The old statement traverses the link:

NSDictionary* attr = [[NSFileManager defaultManager] 
fileAttributesAtPath:file traverseLink:YES];

The problem is that the header states that 'attributesOfItemAtPath:error:' that 
it's a replacement for 'fileAttributesAtPath:traverseLink:', but provides no 
provision for traversing the link.

How would I obtain the attributes of an item that needs to be traversed first?

Thanks,

-- Tito
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Charles Srstka
On May 27, 2010, at 2:43 PM, Bill Appleton wrote:

 *5)** **I **can't create a simple list*
 
 I did it the only way I could -- with a table that has one column, etc. Man
 that was painful for a simple list. Is there a better way?

Have a look at NSArrayController. It makes table views a piece of cake. You set 
one up basically like this:

1. You create an object with an NSArray property, and write the getters and 
setters (or synthesize them).

2. In IB, you drag an NSObjectController into the nib and set its ‘content’ 
outlet to the object in step 1.

3. You now drag an NSArrayController into the nib, and in the Bindings pane of 
its Get Info window, enable its Content Array binding, bind it to your object 
controller, and set the Model Key Path to the name of the property in step 1 
(leave Controller Key at the default, ‘selection’).

4. In the Attributes pane of the NSArrayController’s Get Info window, set Class 
Name to the name of the class of the objects that populate the array.

4. Now, the final step: you select the table column in your NSTableView 
(double-clicking a column body will select the column), bind it to your array 
controller, and set the Value binding to the following: Controller Key is 
arrangedObjects (the default), Model Key Path is the name of a property (or a 
dictionary key, if your objects are NSDictionaries) that will get a nice 
NSString or other displayable object to show in the table column.

And you’re done. Zero code, and your table view is ready to go.

Charles___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSFileManager 'attributesOfItemAtPath:error:' does not traverse a link?

2010-05-28 Thread Charles Srstka
On May 28, 2010, at 10:01 AM, Tito Ciuro wrote:

 The old statement traverses the link:
 
   NSDictionary* attr = [[NSFileManager defaultManager] 
 fileAttributesAtPath:file traverseLink:YES];
 
 The problem is that the header states that 'attributesOfItemAtPath:error:' 
 that it's a replacement for 'fileAttributesAtPath:traverseLink:', but 
 provides no provision for traversing the link.
 
 How would I obtain the attributes of an item that needs to be traversed first?

You can easily traverse a link just by using [file 
stringByResolvingSymlinksInPath] or [file stringByStandardizingPath] instead of 
file. Where this gets tricky is if you *don’t* want to resolve the symlink. 
Currently, the method doesn’t traverse symbolic links, but the documentation 
claims that this behavior could change in a future version of OS X, so if you 
need to guarantee that it won’t resolve, the only options are either to use 
deprecated methods, or to use Carbon or BSD APIs.

Charles___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSFileManager 'attributesOfItemAtPath:error:' does not traverse a link?

2010-05-28 Thread Tito Ciuro
Thanks Charles!

-- Tito

On May 28, 2010, at 5:17 PM, Charles Srstka wrote:

 On May 28, 2010, at 10:01 AM, Tito Ciuro wrote:
 
 The old statement traverses the link:
 
  NSDictionary* attr = [[NSFileManager defaultManager] 
 fileAttributesAtPath:file traverseLink:YES];
 
 The problem is that the header states that 'attributesOfItemAtPath:error:' 
 that it's a replacement for 'fileAttributesAtPath:traverseLink:', but 
 provides no provision for traversing the link.
 
 How would I obtain the attributes of an item that needs to be traversed 
 first?
 
 You can easily traverse a link just by using [file 
 stringByResolvingSymlinksInPath] or [file stringByStandardizingPath] instead 
 of file. Where this gets tricky is if you *don’t* want to resolve the 
 symlink. Currently, the method doesn’t traverse symbolic links, but the 
 documentation claims that this behavior could change in a future version of 
 OS X, so if you need to guarantee that it won’t resolve, the only options are 
 either to use deprecated methods, or to use Carbon or BSD APIs.
 
 Charles

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSFileManager 'attributesOfItemAtPath:error:' does not traverse a link?

2010-05-28 Thread Kevin Perry
That documentation is incorrect and is scheduled to be corrected. 
-attribtuesOfItemAtPath:error: will never automatically resolve symlinks, and 
that will never change.

-Kevin Perry

On May 28, 2010, at 8:17 AM, Charles Srstka wrote:

 On May 28, 2010, at 10:01 AM, Tito Ciuro wrote:
 
 The old statement traverses the link:
 
  NSDictionary* attr = [[NSFileManager defaultManager] 
 fileAttributesAtPath:file traverseLink:YES];
 
 The problem is that the header states that 'attributesOfItemAtPath:error:' 
 that it's a replacement for 'fileAttributesAtPath:traverseLink:', but 
 provides no provision for traversing the link.
 
 How would I obtain the attributes of an item that needs to be traversed 
 first?
 
 You can easily traverse a link just by using [file 
 stringByResolvingSymlinksInPath] or [file stringByStandardizingPath] instead 
 of file. Where this gets tricky is if you *don’t* want to resolve the 
 symlink. Currently, the method doesn’t traverse symbolic links, but the 
 documentation claims that this behavior could change in a future version of 
 OS X, so if you need to guarantee that it won’t resolve, the only options are 
 either to use deprecated methods, or to use Carbon or BSD APIs.
 
 Charles___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/kperry%40apple.com
 
 This email sent to kpe...@apple.com

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Kevin Wojniak

On May 27, 2010, at 12:43 PM, Bill Appleton wrote:

 *4)** **I **can't call the printing code*
 
 I know, the printing code calls me. But other platforms don't work like
 this. I eventually used Core Printing and the Cocoa dialogs by sub-classing
 and faking out NSPrintPanel. Is there a better way?

Can you be more specific? Have you looked at NSPrintOperation 
setShowsPrintPanel: ?

 *5)** **I **can't create a simple list*
 
 I did it the only way I could -- with a table that has one column, etc. Man
 that was painful for a simple list. Is there a better way?

As others have said, but I'll reiterate, bindings make this ridiculously easy.

 *6)** **I **can't get the height of some wrapped text*
 
 I had to use the layout manager and some major rocket science to get this to
 work right. I'm not saying Text Edit was great, but at least it knows how
 tall the text field is.

I have a method for doing this and once the initial data is created and cached, 
it takes 4 lines of code to calculate the height of text for a width. While 
it's not as obvious as -[NSAttributedString size], I certainly wouldn't 
consider it rocket science :). I believe the code originated from Apple's docs 
too.

Kevin

___

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

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

2010-05-28 Thread Uli Kusterer
On May 28, 2010, at 4:00 PM, Sherm Pendley wrote:
 I would let the sent objects handle the work themselves. A switch or
 series of ifs based on class is an OOP anti-pattern. Polymorphism is
 often a better alternative, and Objective-C's ability to add a
 category to any class makes it easy to implement. So,  I would extend
 NSString, UIImage, etc. - whatever types can be sent - by adding a new
 method mySuperDuperMethod (for example).
 
 Then, what you're left with in the receiver class is simply:
 
if ([obj respondsToSelector(@selector(mySuperDuperMethod))]) {
[obj performSelector:@selector(mySuperDuperMethod)];
}
 
 If the ability of a sent object to implement mySuperDuperMethod is
 critical, you could add an else block to log and/or assert any such
 failures.

 This isn't a good choice in many cases, though. It leads people to tack a lot 
of unrelated functionality onto foundational classes. You'd end up with 
everything is a dictionary if you followed through on that.

-- Uli Kusterer
The Witnesses of TeachText are everywhere...



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Bill Appleton
hi all,

wow, i am getting a lot of help solving these last issues! thanks all.

on printing, the problem is that i have to port an enterprise application
that expects to be able to call a fx for the page layout and the page setup
dialog, a fx to begin/end a page, and a fx to begin/end printing.

so Cocoa has this amazing system where you initiate printing and the
printing system CALLS YOU with these requirements, but i need something
where i CALL THEM because i have to port lots of other code.

now, Core Printing implements all this EXCEPT the dialogs, they are
deprecated in 64 bit, so the missing call is PMSessionPrintDialog

so [NSApp runPageLayout] handles page layout no worries, but NSPrintPanel
can only run the page setup dialog in the context of printing an NSView, and
then you get all the callbacks which i can't implement.

so i needed a way to edit the shared printing info with the standard page
setup dialog, then i can get a copy of the shared printing info  call Core
Printing, all is well

so i did that by subclassing NSPrintPanel and makeing it return cancel to
NSPrintOperation even when the shared printing info was actually edited

so that is a rather nasty solution -- but basically anyone trying to port a
large code base with printing is going to run right into this issue
unless i'm missing something



best,

bill







On Fri, May 28, 2010 at 9:04 AM, Kevin Wojniak kain...@kainjow.com wrote:


 On May 27, 2010, at 12:43 PM, Bill Appleton wrote:

  *4)** **I **can't call the printing code*
 
  I know, the printing code calls me. But other platforms don't work like
  this. I eventually used Core Printing and the Cocoa dialogs by
 sub-classing
  and faking out NSPrintPanel. Is there a better way?

 Can you be more specific? Have you looked at NSPrintOperation
 setShowsPrintPanel: ?

  *5)** **I **can't create a simple list*
 
  I did it the only way I could -- with a table that has one column, etc.
 Man
  that was painful for a simple list. Is there a better way?

 As others have said, but I'll reiterate, bindings make this ridiculously
 easy.

  *6)** **I **can't get the height of some wrapped text*
 
  I had to use the layout manager and some major rocket science to get this
 to
  work right. I'm not saying Text Edit was great, but at least it knows how
  tall the text field is.

 I have a method for doing this and once the initial data is created and
 cached, it takes 4 lines of code to calculate the height of text for a
 width. While it's not as obvious as -[NSAttributedString size], I certainly
 wouldn't consider it rocket science :). I believe the code originated from
 Apple's docs too.

 Kevin


___

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

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

2010-05-28 Thread Greg Guerin

Chris Idou wrote:

I've got an app that needs to send out emails. I'm trying to import  
mail settings from Mail.app. For some reason my keychain has  
passwords for smtp.gmail.com, but not for smtp.me.com.



AFAIK, there is only the one MobileMe password for all uses.

Double-click your MobileMe password in Keychain Access.app and look  
at its Access Control tab.  Note that Mail.app is always granted  
access by default.


  -- GG

___

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

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

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

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


Re: six things I wasn't able to do with Cocoa

2010-05-28 Thread Ricky Sharp

On May 28, 2010, at 11:20 AM, Bill Appleton wrote:

 on printing, the problem is that i have to port an enterprise application
 that expects to be able to call a fx for the page layout and the page setup
 dialog, a fx to begin/end a page, and a fx to begin/end printing.
 
 so Cocoa has this amazing system where you initiate printing and the
 printing system CALLS YOU with these requirements, but i need something
 where i CALL THEM because i have to port lots of other code.


Have you considered creating a go-between object that would implement the 
APIs your code expects.  And, would also implement the required Cocoa delegate 
APIs?  Your app code then sets info/state on your object which in turn can be 
passed along when the Cocoa delegate methods get called.

Note that this may be an extreme simplification.  I have no idea on the order 
of operations of both APIs and thus don't know if they will work well together 
using this approach.

Maintaining state in your go-between object may also get tricky.
___
Ricky A. Sharp mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Bill Appleton
Hi Chaitanya,

that code always returns a size of 100, 100 for every movie I try. really.

and then the poster or frame is really pixelated because it is coming from
such a small source.

i am surely missing something here!


thanks,

bill





On Fri, May 28, 2010 at 1:17 AM, Chaitanya Pandit chaita...@expersis.comwrote:


 *3)** **I **can't get t**he right dimensions for a QuickTime movie or
 poster
 *


 NSSize movieSize =  [[movieObject currentFrameImage] size];

 I used to call GetMovieBox, so I tried using [QTMovie posterImage] but the
 NSImage reported a width and height of 100, and then my movie poster was
 really pixelated. How do I get a decent looking movie poster? How do I get
 the original dimensions for movie playback?


 *4)** **I **can't call the printing code*

 I know, the printing code calls me. But other platforms don't work like
 this. I eventually used Core Printing and the Cocoa dialogs by sub-classing
 and faking out NSPrintPanel. Is there a better way?


 *5)** **I **can't create a simple list*

 I did it the only way I could -- with a table that has one column, etc. Man
 that was painful for a simple list. Is there a better way?


 *6)** **I **can't get the height of some wrapped text*

 I had to use the layout manager and some major rocket science to get this
 to
 work right. I'm not saying Text Edit was great, but at least it knows how
 tall the text field is.




 Thanks!


 Bill Appleton
 ___

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

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

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

 This email sent to chaita...@expersis.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: Notification of file system modification arrives too early?

2010-05-28 Thread Scott Ribe
On May 28, 2010, at 7:57 AM, Antonio Nunes wrote:

 I expect many of the files will arrive in the watched folder either through 
 user manipulation in the Finder or through scripts/automation. I don't think 
 I can assume only Finder-originated copying.

Then there's no way for the system to know when the operation is done. The 
file being closed would be a very good candidate, but not necessarily... Even 
more so, the file being open doesn't necessarily mean it's still being copied 
(Spotlight, for instance).

Generally the most reliable way to deal with this is requirements on the 
process putting the file in the folder. In other words do not copy, and most 
certainly do not download, a file to the final name/location from where it will 
be picked up. Copy (or download) to a temporary file, distinguished by name or 
extension or type or visibility or location, then when the file is complete 
rename/update/move.

If you're only dealing with PDF files, you could check for the presence of the 
PDF footer at the end of the file. That would work unless some process creates 
a complete PDF file, then appends pages to it.

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Kevin Wojniak
Did you try QTMovieNaturalSizeAttribute?

http://developer.apple.com/mac/library/technotes/tn2005/tn2138.html#TNTAG11


On May 28, 2010, at 9:43 AM, Bill Appleton wrote:

 Hi Chaitanya,
 
 that code always returns a size of 100, 100 for every movie I try. really.
 
 and then the poster or frame is really pixelated because it is coming from
 such a small source.
 
 i am surely missing something here!
 
 
 thanks,
 
 bill
 
 
 
 
 
 On Fri, May 28, 2010 at 1:17 AM, Chaitanya Pandit 
 chaita...@expersis.comwrote:
 
 
 *3)** **I **can't get t**he right dimensions for a QuickTime movie or
 poster
 *
 
 
 NSSize movieSize =  [[movieObject currentFrameImage] size];
 
 I used to call GetMovieBox, so I tried using [QTMovie posterImage] but the
 NSImage reported a width and height of 100, and then my movie poster was
 really pixelated. How do I get a decent looking movie poster? How do I get
 the original dimensions for movie playback?
 
 
 *4)** **I **can't call the printing code*
 
 I know, the printing code calls me. But other platforms don't work like
 this. I eventually used Core Printing and the Cocoa dialogs by sub-classing
 and faking out NSPrintPanel. Is there a better way?
 
 
 *5)** **I **can't create a simple list*
 
 I did it the only way I could -- with a table that has one column, etc. Man
 that was painful for a simple list. Is there a better way?
 
 
 *6)** **I **can't get the height of some wrapped text*
 
 I had to use the layout manager and some major rocket science to get this
 to
 work right. I'm not saying Text Edit was great, but at least it knows how
 tall the text field is.
 
 
 
 
 Thanks!
 
 
 Bill Appleton
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/chaitanya%40expersis.com
 
 This email sent to chaita...@expersis.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/kainjow%40kainjow.com
 
 This email sent to kain...@kainjow.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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Wade Williams

On May 28, 2010, at 11:04 AM, Kevin Wojniak wrote:

 *4)** **I **can't call the printing code*
 
 I know, the printing code calls me. But other platforms don't work like
 this. I eventually used Core Printing and the Cocoa dialogs by sub-classing
 and faking out NSPrintPanel. Is there a better way?
 
 Can you be more specific? Have you looked at NSPrintOperation 
 setShowsPrintPanel: ?
 
 


I haven't read the entire thread so apologies if I'm missing something, but 
this snippet brings back a memory and I wonder if the same thing is happening 
to you.

I wanted to write a simple application that included printing.  All I wanted to 
do was print my NSView.  

I was coming from a C++ background, so I started looking around for a print 
manager object to give me a printer object to subclass.  I searched high and 
low.  I could find things that looked like they were close, but nothing really 
matched up.  How stupid could Cocoa be I thought?  All I want to do is get a 
reference to the default printer, and call some printWithObject method and 
pass it my view.  I spent hours looking and couldn't believe Cocoa could make 
something so simple so complex.

The problem of course was that I was coming at it from a C++ background and 
trying to shoehorn my C++ thinking onto Cocoa.

So, what did the solution end up being?

[myView print];

The lesson?  If it seems ridiculously hard, you're likely making it hard with 
incorrect assumptions.  Cocoa likely has an easier way.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Sean McBride
On Thu, 27 May 2010 12:43:42 -0700, Bill Appleton said:

*2)** **I **can't **get the current caret blink rate in milliseconds*

I used to call GetCaretTime, but now I just use 500 milliseconds. Eeek!
Where is the current blink rate? Please don't tell me I don't need it, we
implement our own scripting engine, etc.

Oddly, GetCaretTime is not deprecated but is removed in 64 bit.  So much
for advanced warning.  :)  I thought there might be a substitute in
event_status_driver.h, but didn't see anything.  You could always still
use GetCaretTime in a 32bit process and pass its result back to your
main process.

--

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: six things I wasn't able to do with Cocoa

2010-05-28 Thread James Walker

On 5/27/2010 12:43 PM, Bill Appleton wrote:

*1) I can't hide a file, or test if a file is hidden*

I had to resort to FSGetCatalogInfo -- there is no way to do it through
NSFileManager, etc. Right?


Since there are several ways to hide a file, I don't think 
FSGetCatalogInfo will necessarily tell you if a file is invisible.  The 
right way (before 10.6, anyway) is to use LSCopyItemAttribute with the 
attribute kLSItemExtensionIsHidden.

--
  James W. Walker, Innoventive Software LLC
  http://www.frameforge3d.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


Spotlight SDK replacement on iPad/iPhone

2010-05-28 Thread sebi
Hello,

I'd like to have a quick full text search on a pdf in my app. Unfortunately the 
NSMetadata* classes are not available in the iPhone SDK. Does someone know of a 
3rd party solution or so?

Thanks and regards,
sebastian mecklenburg___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Alastair Houghton
On 28 May 2010, at 18:25, James Walker wrote:

 On 5/27/2010 12:43 PM, Bill Appleton wrote:
 *1) I can't hide a file, or test if a file is hidden*
 
 I had to resort to FSGetCatalogInfo -- there is no way to do it through
 NSFileManager, etc. Right?
 
 Since there are several ways to hide a file, I don't think FSGetCatalogInfo 
 will necessarily tell you if a file is invisible.  The right way (before 
 10.6, anyway) is to use LSCopyItemAttribute with the attribute 
 kLSItemExtensionIsHidden.

I don't think that's the right thing at all.  kLSItemExtensionIsHidden would 
seem to be talking about the *extension*.

Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


Re: six things I wasn't able to do with Cocoa

2010-05-28 Thread James Walker

On 5/28/2010 11:18 AM, Alastair Houghton wrote:

On 28 May 2010, at 18:25, James Walker wrote:


On 5/27/2010 12:43 PM, Bill Appleton wrote:

*1) I can't hide a file, or test if a file is hidden*

I had to resort to FSGetCatalogInfo -- there is no way to do it through
NSFileManager, etc. Right?


Since there are several ways to hide a file, I don't think FSGetCatalogInfo 
will necessarily tell you if a file is invisible.  The right way (before 10.6, 
anyway) is to use LSCopyItemAttribute with the attribute 
kLSItemExtensionIsHidden.


I don't think that's the right thing at all.  kLSItemExtensionIsHidden would 
seem to be talking about the *extension*.


Oops, I was half right.  Right function, wrong attribute; 
kLSItemIsInvisible is what is needed.


--
  James W. Walker, Innoventive Software LLC
  http://www.frameforge3d.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


Changing cursors in window's bounds

2010-05-28 Thread John Love
I do not have a custom view, rather just the window's contentView with its 
various graphics, buttons, text etc.  I wish to simply change the cursor 
anytime the mouse is inside any part of this contentView.

If I did have a custom view, I understand all the machinations pertaining to 
changing cursors, e.g., NSView's initWithRect:, addTrackingArea:, and 
cursorUpdate:  Thanks to Apple's TrackIt Project, it all seems straightforward.

My challenge centers on trying to make this magic happen just in the window's 
canned contentView without creating a custom NSView within Interface Builder.  
My sub-classed NSDocument knows about the window via my overridden 
-windowControllerDidLoadNib:(NSWindowController *)aController because its 
window = [aController window].  Also,  I have one Controller (sub to NSObject) 
which has knowledge of the NSDocument's NSWindow because I pass this window to 
it.

So, how do I effect cursor tracking just in this window without creating a 
custom NSView in IB?

John Love
Touch the Future! Teach!



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Bill Appleton
hi Kevin,

sorry if this is a repost, my last one was rejected for being too big

YES, the QTMovieNaturalSizeAttribute definitely returns the size i am
looking for

the remaining problem is that the movie posetr returns a size of 100 x 100

so when i capture the poster it is really pixelated

i've tried everything -- how do other people get movie posters and/or grab
movie frames?


best,

bill






On Fri, May 28, 2010 at 9:52 AM, Kevin Wojniak kain...@kainjow.com wrote:

 Did you try QTMovieNaturalSizeAttribute?

 http://developer.apple.com/mac/library/technotes/tn2005/tn2138.html#TNTAG11


 On May 28, 2010, at 9:43 AM, Bill Appleton wrote:

  Hi Chaitanya,
 
  that code always returns a size of 100, 100 for every movie I try.
 really.
 
  and then the poster or frame is really pixelated because it is coming
 from
  such a small source.
 
  i am surely missing something here!
 
 
  thanks,
 
  bill
 
 
 
 
 
  On Fri, May 28, 2010 at 1:17 AM, Chaitanya Pandit 
 chaita...@expersis.comwrote:
 
 
  *3)** **I **can't get t**he right dimensions for a QuickTime movie or
  poster
  *
 
 
  NSSize movieSize =  [[movieObject currentFrameImage] size];
 
  I used to call GetMovieBox, so I tried using [QTMovie posterImage] but
 the
  NSImage reported a width and height of 100, and then my movie poster was
  really pixelated. How do I get a decent looking movie poster? How do I
 get
  the original dimensions for movie playback?
 
 
  *4)** **I **can't call the printing code*
 
  I know, the printing code calls me. But other platforms don't work like
  this. I eventually used Core Printing and the Cocoa dialogs by
 sub-classing
  and faking out NSPrintPanel. Is there a better way?
 
 
  *5)** **I **can't create a simple list*
 
  I did it the only way I could -- with a table that has one column, etc.
 Man
  that was painful for a simple list. Is there a better way?
 
 
  *6)** **I **can't get the height of some wrapped text*
 
  I had to use the layout manager and some major rocket science to get
 this
  to
  work right. I'm not saying Text Edit was great, but at least it knows
 how
  tall the text field is.
 
 
 
 
  Thanks!
 
 
  Bill Appleton
  ___
 
  Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
  Please do not post admin requests or moderator comments to the list.
  Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
  Help/Unsubscribe/Update your Subscription:
 
 http://lists.apple.com/mailman/options/cocoa-dev/chaitanya%40expersis.com
 
  This email sent to chaita...@expersis.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/kainjow%40kainjow.com
 
  This email sent to kain...@kainjow.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: Changing cursors in window's bounds

2010-05-28 Thread Quincey Morris
On May 28, 2010, at 11:55, John Love wrote:

 My challenge centers on trying to make this magic happen just in the window's 
 canned contentView without creating a custom NSView within Interface Builder. 
  My sub-classed NSDocument knows about the window via my overridden 
 -windowControllerDidLoadNib:(NSWindowController *)aController because its 
 window = [aController window].  Also,  I have one Controller (sub to 
 NSObject) which has knowledge of the NSDocument's NSWindow because I pass 
 this window to it.
 
 So, how do I effect cursor tracking just in this window without creating a 
 custom NSView in IB?

A NSTrackingArea has an owner, which doesn't have to be a view, and which 
receives the tracking area's messages. So just make your window controller or 
your document the owner.

The only problem is that I have a *vague* recollection that there's something 
special about the cursorUpdate: message. It might be that this is the only one 
of NSTrackingArea's generated messages that's sent to the view under the cursor 
instead of the owner. But I'm likely misremembering, so you should give it a 
try.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Alex Curylo

On 2010-05-28, at 12:02 PM, cocoa-dev-requ...@lists.apple.com wrote:

 i've tried everything -- how do other people get movie posters and/or grab
 movie frames?

With classic QuickTime if there was no poster frame specifically set in the 
movie QuickTime would reliably return the first frame. With QuickTimeKit that 
is ... inconsistent. Safest to just grab the first frame yourself.

As for capturing frames, here's the I believe currently recommended way to do 
it:

   NSDictionary *imageAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
  QTMovieFrameImageTypeNSImage, QTMovieFrameImageType,
  [NSArray arrayWithObject:@NSBitmapImageRep], 
QTMovieFrameImageRepresentationsType,
  [NSNumber numberWithBool:YES], QTMovieFrameImageDeinterlaceFields,
  [NSNumber numberWithBool:YES], QTMovieFrameImageHighQuality,
  [NSNumber numberWithBool:YES], QTMovieFrameImageSingleField,
  nil
   ];

   QTTime captureTime = [0 .. self.movie.duration];

   NSError *captureError = nil;
   NSImage *captureFullFrame = [self.movie frameImageAtTime:captureTime
  withAttributes:imageAttrs
  error:captureError
   ];

That allows for a variety of other image types besides 
QTMovieFrameImageTypeNSImage, but is QuickTime 7.2 dependent. If you need older 
version compatibility, use

- (NSImage *)frameImageAtTime:(QTTime)time;

Either way, these should only be called on the main thread. Theoretically you 
can detach movies and move them around between threads, but you have a good 
chance of running into issues doing so, particularly if you're working with 
QTKit captured movies; something about the rendering context I think, although 
the details are old enough to be kinda fuzzy now. Safer to just call 
performSelectorOnMainThread: to get each grabbed frame if you've got a 
background renderer or suchlike, I'd say.

-- 
Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/

...the variable PI can be given that value [3.141592653589793] with
 a DATA statement. This simplifies the modifying of the program,
 should the value of PI ever change. -- SDS Sigma series Fortran manual 



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Spotlight SDK replacement on iPad/iPhone

2010-05-28 Thread Laurent Cerveau
You can try swish-e. Pretty good stuff. I still wish SearchKit would  
be public on the iPhoneOS


Laurent

Sent from my road phone


On May 28, 2010, at 7:58 PM, sebi s...@happyhappyboy.de wrote:


Hello,

I'd like to have a quick full text search on a pdf in my app.  
Unfortunately the NSMetadata* classes are not available in the  
iPhone SDK. Does someone know of a 3rd party solution or so?


Thanks and regards,
sebastian mecklenburg___

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

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

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

This email sent to lcerv...@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: NSURLConnection weirdiness

2010-05-28 Thread Jens Alfke

On May 28, 2010, at 2:58 AM, Nava Carmon wrote:

 sometimes it's just stuck after initialing and don't get into connection's 
 delegate methods. I'm working with WiFi  3G and the same server all the 
 time. When it comes to didFailWithError i see that mostly it was a timeout 
 error.

Do you mean that it does eventually fail with a timeout error, or that it never 
calls the delegate at all?

If you’re connecting over 3G, I would expect random failures once in a while, 
as it’s a less reliable network. 

—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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Robert Martin
Try using the QTMovie method frameImageAtTime: withAttributes: error:

You can specify the image size you want returned in the attributes dictionary 
(along with the image format).



On May 28, 2010, at 2:55 PM, Bill Appleton wrote:

 the remaining problem is that the movie posetr returns a size of 100 x 100
 
 so when i capture the poster it is really pixelated
 
 i've tried everything -- how do other people get movie posters and/or grab
 movie frames?
 

___

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

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

2010-05-28 Thread Jens Alfke

 On May 28, 2010, at 2:25 AM, Philip Vallone wrote:
 This is a relative question, which depends on how the data is coming and 
 going. My question comes from the following situation. Suppose I have a 
 GKSession that is passing information via Bluetooth. The sender can send any 
 type of information (NSString, UIImage etc...). The receiver needs to know 
 how to handle this data. If there is a better way... Then how?

Wait, are you archiving and unarchiving data over a network? That’s a bad idea 
unless you’re extremely careful. The problem is that a malicious peer can send 
you an archive that expands into any codable object, not just the types you 
were expecting; this can be exploited to do Bad Things in your process, like 
crashing and possibly worse.

It would be safer and easier to send property lists instead. The property list 
decoder is safe in that it will only ever output a known set of classes. You 
just have to watch out that your code never takes type types of incoming data 
for granted, otherwise it can throw assertion failures if it gets the wrong 
data. So instead of
NSString *cmd = [message objectForKey: @“command”];
you have to do something like
id cmd = [message objectForKey: @“command”];
if (![cmd isKindOfClass: [NSString class]])
return NO; // reject the message as invalid
My MYUtilities library has a macro called $castIf that makes this really easy:
NSString *cmd = $castIf(NSString, [message objectForKey: @“command”]);
It returns nil if the object isn’t of the required class.

Yes, checking classes at runtime is often a bad-code smell. But it’s not 
avoidable when working with untrusted data and untyped data structures like 
plists. You have to code defensively on the assumption that any message you 
receive might be corrupt or malicious.

—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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Jens Alfke

On May 27, 2010, at 12:43 PM, Bill Appleton wrote:

 there were some things i
 noticed that i couldn't do easily in Cocoa or any other 64 bit OSX API.

Cocoa doesn’t claim to do everything. There are a lot of tasks that should be 
done using lower level APIs.

 *1) I can't hide a file, or test if a file is hidden*
 I had to resort to FSGetCatalogInfo

I’m pretty sure FSGetCatalogInfo is available in 64-bit. It’s not deprecated 
and it’s not part of the High-Level Toolbox.

 *2)** **I **can't **get the current caret blink rate in milliseconds*
 I used to call GetCaretTime, but now I just use 500 milliseconds. Eeek!

OS X hasn’t ever had a UI to change the caret blink time, so I think you can 
safely hardcode it.

(Although I can’t think of why you’d need this unless you’re implementing your 
own text editing system from scratch, which is a pretty scary thought. If 
you’re doing that, there are a zillion other expected text behaviors you’ll 
need to get right, that are a lot more important than the blink rate.)

—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: six things I wasn't able to do with Cocoa

2010-05-28 Thread Bill Appleton
hi all,

i fixed the movie poster problem as well

thanks for all the help, this is a great forum

have a nice weekend!


best,

bill






On Fri, May 28, 2010 at 1:28 PM, Robert Martin robmar...@frontiernet.netwrote:

 Try using the QTMovie method frameImageAtTime: withAttributes: error:

 You can specify the image size you want returned in the attributes
 dictionary (along with the image format).



 On May 28, 2010, at 2:55 PM, Bill Appleton wrote:

  the remaining problem is that the movie posetr returns a size of 100 x
 100
 
  so when i capture the poster it is really pixelated
 
  i've tried everything -- how do other people get movie posters and/or
 grab
  movie frames?
 


___

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

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

2010-05-28 Thread Philip Vallone
Hi,

 Wait, are you archiving and unarchiving data over a network? That’s a bad 
 idea unless you’re extremely careful. The problem is that a malicious peer 
 can send you an archive that expands into any codable object, not just the 
 types you were expecting; this can be exploited to do Bad Things in your 
 process, like crashing and possibly worse.

How is it possible using GKSession to be introduced to a malicious peer.? I am 
creating a GKSession object and connecting via GKPeerPickerController. A hand 
shack is made between the the two peers. Once both peers accept the connection, 
the session is stored along with the peer id. This information can be checked 
before any information is received. Isn't this secure enough?  

Thanks,

Phil


On May 28, 2010, at 4:40 PM, Jens Alfke wrote:

 
 On May 28, 2010, at 2:25 AM, Philip Vallone wrote:
 This is a relative question, which depends on how the data is coming and 
 going. My question comes from the following situation. Suppose I have a 
 GKSession that is passing information via Bluetooth. The sender can send 
 any type of information (NSString, UIImage etc...). The receiver needs to 
 know how to handle this data. If there is a better way... Then how?
 
 Wait, are you archiving and unarchiving data over a network? That’s a bad 
 idea unless you’re extremely careful. The problem is that a malicious peer 
 can send you an archive that expands into any codable object, not just the 
 types you were expecting; this can be exploited to do Bad Things in your 
 process, like crashing and possibly worse.
 
 It would be safer and easier to send property lists instead. The property 
 list decoder is safe in that it will only ever output a known set of classes. 
 You just have to watch out that your code never takes type types of incoming 
 data for granted, otherwise it can throw assertion failures if it gets the 
 wrong data. So instead of
   NSString *cmd = [message objectForKey: @“command”];
 you have to do something like
   id cmd = [message objectForKey: @“command”];
   if (![cmd isKindOfClass: [NSString class]])
   return NO; // reject the message as invalid
 My MYUtilities library has a macro called $castIf that makes this really easy:
   NSString *cmd = $castIf(NSString, [message objectForKey: @“command”]);
 It returns nil if the object isn’t of the required class.
 
 Yes, checking classes at runtime is often a bad-code smell. But it’s not 
 avoidable when working with untrusted data and untyped data structures like 
 plists. You have to code defensively on the assumption that any message you 
 receive might be corrupt or malicious.
 
 —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: isKindofClass with NSData and NSKeyUnarchiver

2010-05-28 Thread Kyle Sluder
On May 28, 2010, at 4:40 PM, Philip Vallone  
philip.vall...@verizon.net wrote:


How is it possible using GKSession to be introduced to a malicious  
peer.? I am creating a GKSession object and connecting via  
GKPeerPickerController. A hand shack is made between the the two  
peers. Once both peers accept the connection, the session is stored  
along with the peer id. This information can be checked before any  
information is received. Isn't this secure enough?


Always assume your peer is malicious. Malicious behavior is a subset  
of possible errant behaviors.


--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: isKindofClass with NSData and NSKeyUnarchiver

2010-05-28 Thread Michael Ash
On Fri, May 28, 2010 at 7:40 PM, Philip Vallone
philip.vall...@verizon.net wrote:
 Hi,

 Wait, are you archiving and unarchiving data over a network? That’s a bad 
 idea unless you’re extremely careful. The problem is that a malicious peer 
 can send you an archive that expands into any codable object, not just the 
 types you were expecting; this can be exploited to do Bad Things in your 
 process, like crashing and possibly worse.

 How is it possible using GKSession to be introduced to a malicious peer.? I 
 am creating a GKSession object and connecting via GKPeerPickerController. A 
 hand shack is made between the the two peers. Once both peers accept the 
 connection, the session is stored along with the peer id. This information 
 can be checked before any information is received. Isn't this secure enough?

An attacker can execute a man-in-the-middle attack, wherein he talks
to two copies of your app and passes data between them, such that they
think they're talking directly to each other, but then modifies data
maliciously.

An attacker can simply impersonate your app, responding like a real
client, but sending malicious data when desired.

Neither of these can be defended against, even theoretically, when
communicating peer-to-peer. (It is possible to defend against them
when communicating with a server by using digital signature
technology, but this doesn't work when the attacker has direct access
to the program he wants to impersonate.)

In short, you should treat any data coming from the network as
potentially evil, always.

Mike
___

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

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

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

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


Re: NSURLConnection weirdiness

2010-05-28 Thread Jerry Krinock

On 2010 May 28, at 02:58, Nava Carmon wrote:

 When I enter same link in Safari it takes a second to bring data.

I understand that you're saying it works OK at the same time from the same IP 
address from Safari, meaning that you have ruled out being throttled by this 
certain server, or your ISP.  OK, because these would be the first two 
suspects on my list.

 And after another trial I can access the link.

I'm assuming you mean exactly the same URL.  Some servers give better service 
to web browsers than to apps requesting via their API.

 What might be the reason for such a weird behavior?  How can I improve it?

You're going to have to discover a pattern.  For another data point with these 
types of problems, you'll usually want to open a Terminal window and send your 
request using the unix command curl(1).

 What is the role of cache policy with NSURLConnection?

Long answer:

http://developer.apple.com/mac/library/documentation/cocoa/conceptual/URLLoadingSystem/Concepts/CachePolicies.html

For consistency in testing, you'll probably want to use 
NSURLRequestReloadIgnoringCacheData.

Let us know if you find anything interesting.  Actually, a better list for this 
question would be macnetworkp...@lists.apple.com.

___

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

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

2010-05-28 Thread Jens Alfke

On May 28, 2010, at 6:59 PM, Michael Ash wrote:

 An attacker can execute a man-in-the-middle attack...
 An attacker can simply impersonate your app...
 Neither of these can be defended against, even theoretically, when 
 communicating peer-to-peer.

Not true; if you use SSL or some equivalent, both peers can use certificates to 
identify themselves. This works if either (a) the certs are signed by a 
reputable authority (as in the traditional use of SSL by web servers), or if 
(b) each peer has previously verified the other’s identity and remembered the 
cert (as is done by SSH.)

GameKit doesn’t do anything like this, though, although I can’t say for sure 
because Apple’s never published any information about the protocol used (to my 
knowledge).

—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


Help w/ first step of creating Help Book for app

2010-05-28 Thread Shane
I'm trying to create a help book for my app using the Apple Help
Programming Guide, which is not easy for me to follow. I'm at the
section Creating a Basic Help Book, trying to get the structure
right where the HTML files are to go. It says I should have a dir
structure like:

SurfWriter.app/ (I'm guessing this is the top level folder under
Groups  Files of my XCode view).
Contents/
Resources/
SurfWriter.help/
Contents/
  Info.plist
  Resources/
  shrd/
  English.lproj/
  pgs/
  gfx/
  sty/
  scrpt/

Should I just add in the Groups  Files view of XCode a group, or do
I actually create directories with these names? I don't even have a
'Contents' directory in the top level of my XCode project so I'm
guessing I have to create every one of these which I don't have in my
current project.

Under Groups  Files of my XCode project, I have for the most part,
the following:

MyApp
Source
Controllers
Delegates
Models
Servers
Views
Includes
Resources
Frameworks
Products
Targets
Executables
Find Results
Bookmarks
SCM
Project Symbols
Implementation Files
Interface Builder Files
___

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

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

2010-05-28 Thread Shane
 [path moveToPoint:NSMakePoint(cellFrame.origin.x, cellFrame.size.height)];
 [path lineToPoint:NSMakePoint(cellFrame.size.width, cellFrame.size.height)];


 If cellFrame = {500, 300, 120, 20}

 You're drawing from {500, 20} to {120, 20}


I have four NSView cell's (so I have four data table header cells,
i.e. 4 columns), and here's the cellFrame values as output by the
NSLog statement above.

x:249 y:0 width:367 height:17
x:146 y:0 width:103 height:17
x:43 y:0 width:103 height:17
x:0 y:0 width:43 height:17

This seems correct. My first cell is trying to draw from x=0 with a width of 43.
My second cell is trying to draw from x=43 with a width of 103.
Third cell is drawing from x=146 with width of 103.
And fourth cell is drawing from x=249 with width of 367.

Yet, it's like each border is overwriting itself starting from 0 (the
leftmost cell).

- (void) drawInteriorWithFrame:(NSRect) cellFrame inView:(NSView *) controlView
{
 NSLog(@x:%g y:%g width:%g height:%g, cellFrame.origin.x,
   cellFrame.origin.y, cellFrame.size.width, 
cellFrame.size.height);

[[NSColor whiteColor] set];
[[NSBezierPath bezierPathWithRect:cellFrame] fill]; 

NSBezierPath *path = [NSBezierPath bezierPath];

[path moveToPoint:NSMakePoint(cellFrame.origin.x, 
cellFrame.size.height)];
[path lineToPoint:NSMakePoint(cellFrame.size.width, 
cellFrame.size.height)];

[[NSColor darkGrayColor] setStroke];

[path stroke];

[super drawInteriorWithFrame:cellFrame inView:controlView];

return;
}

The image attachment on the previous email shows that the line from
the first cell is actually length 103 and it should only be length 43
to cover just that first cell, so I believe somehow it is overwriting
and starting from 0, though the x origin shows otherwise.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 w/ first step of creating Help Book for app

2010-05-28 Thread Ron Fleckner


On 29/05/2010, at 2:29 PM, Shane wrote:


I'm trying to create a help book for my app using the Apple Help
Programming Guide, which is not easy for me to follow...


Stop right there!

Fortunately, Matt Neuburg has created a very helpful short movie  
showing exactly how to do this.  As Matt says at the bottom of this  
page:http://groups.jonzu.com/z_apple_possible-reasons-why-no-help-is-available.html 
,


This problem is nearly always caused by DNFD (Did Not Follow  
Directions). Apple has provided the directions. Follow them! Follow  
them very, very exactly.

I’ve made a tutorial movie laying stress on the key points:

http://www.apeth.com/writersua/implementAppleHelp.mov;



I strongly urge you to have a look.

Ron


___

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

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